1

OAuthCredentials에 사용할 수 있도록 Outlook Web Add-in에서 OAuth 토큰을 얻으려면 office-js-helpers을 사용하고 있습니다. EWS Managed API (코드는 ASP.NET 웹 API를 사용하는 Azure App 서비스에 있습니다).Azure 응용 프로그램 매니페스트가 Outlook Web Add-in에서 office-js-helpers로 인증을 시도하는 중

oauth2AllowImplicitFlow를 true로 설정 한 네이티브 응용 프로그램으로 Office 365 테넌트 (예 : myapplet.onmicrosoft.com, 웹 응용 프로그램을 호스팅하는 Azure 구독이 아님)에 응용 프로그램 등록을 구성했습니다. . 웹/API 앱 대신 네이티브 앱 유형을 사용하여 예기치 않은 오류를 우회하여 앱 승인이 필요함을 나타냅니다 (애플리케이션 권한이 필요하지 않음에도 불구하고).하지만 그건 또 다른 이야기입니다 (어쨌든 Native를 사용해야합니다. .

앱 등록의 리디렉션 URI (일명 답장 URL)가 Outlook 추가 기능 (예 : https://mywebapp.azurewebsites.net/MessageRead.html)과 동일한 페이지를 가리키는 지 확인했습니다. 이것은 내가 사용하고 코드가

<AppDomains> 
<AppDomain>https://login.windows.net</AppDomain> 
<AppDomain>https://login.microsoftonline.com</AppDomain> 
</AppDomains> 

: 나는 또한 내 추가 기능의 매니페스트 권한의 URL을 추가해야했다

{ "appId": "a11aaa11-1a5c-484a-b1d6-86c298e8f250", "appRoles": [], "availableToOtherTenants": true, "displayName": "My App", "errorUrl": null, "groupMembershipClaims": null, "optionalClaims": null, "acceptMappedClaims": null, "homepage": "https://myapp.azurewebsites.net/MessageRead.html", "identifierUris": [], "keyCredentials": [], "knownClientApplications": [], "logoutUrl": null, "oauth2AllowImplicitFlow": true, "oauth2AllowUrlPathMatching": false, "oauth2Permissions": [], "oauth2RequiredPostResponse": false, "objectId": "a11aaa11-99a1-4044-a950-937b484deb8e", "passwordCredentials": [], "publicClient": true, "supportsConvergence": null, "replyUrls": [ "https://myapp.azurewebsites.net/MessageRead.html" ], "requiredResourceAccess": [ { "resourceAppId": "00000003-0000-0000-c000-000000000000", "resourceAccess": [ { "id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d", "type": "Scope" } ] }, { "resourceAppId": "00000002-0000-0000-c000-000000000000", "resourceAccess": [ { "id": "311a71cc-e848-46a1-bdf8-97ff7156d8e6", "type": "Scope" }, { "id": "a42657d6-7f20-40e3-b6f0-cee03008a62a", "type": "Scope" } ] }, { "resourceAppId": "00000002-0000-0ff1-ce00-000000000000", "resourceAccess": [ { "id": "2e83d72d-8895-4b66-9eea-abb43449ab8b", "type": "Scope" }, { "id": "ab4f2b77-0b06-4fc1-a9de-02113fc2ab7c", "type": "Scope" }, { "id": "5eb43c10-865a-4259-960a-83946678f8dd", "type": "Scope" }, { "id": "3b5f3d61-589b-4a3c-a359-5dd4b5ee5bd5", "type": "Scope" } ] } ], "samlMetadataUrl": null }

: 여기

내 응용 프로그램 매니페스트입니다 office-js-helpers를 통한 인증을위한 추가 기능에서 :

// The Office initialize function must be run each time a new page is loaded. 
Office.initialize = function(reason) { 
    $(document).ready(function() { 

     // Determine if we are running inside of an authentication dialog 
     // If so then just terminate the running function 

     if (OfficeHelpers.Authenticator.isAuthDialog()) { 
      // Adding code here isn't guaranteed to run as we need to close the dialog 
      // Currently we have no realistic way of determining when the dialog is completely 
      // closed. 
      return; 
     } 

     // Create a new instance of Authenticator 
     var authenticator = new OfficeHelpers.Authenticator(); 

     authenticator.endpoints.registerAzureADAuth('a11aaa11-1a5c-484a-b1d6-86c298e8f250', 'mytenant.onmicrosoft.com'); 

     // Add event handler to the button 
     $('#login').click(function() { 
      $('#token', window.parent.document).text('Authenticating...'); 

      authenticator.authenticate('AzureAD', true) 
       .then(function (token) { 
        // Consume and store the acess token 
        $('#token', window.parent.document).text(prettify(token)); 
        authToken = token.access_token; 
       }) 
       .catch(function (error) { 
        // Handle the error 
        $('#token', window.parent.document).text(prettify(error)); 
       }); 
     }); 
    }); 
}; 

지금 추가 기능의 코드가 제대로 사용자가 로그인하고 필요한 권한을 요청하지만, 클릭 한 후 다음과 같은 오류가 반환됩니다 응용 프로그램 인증 단계 버튼을 수락 할 수 있습니다

AADSTS50011 : 회신 주소 'https://mywebapp.azurewebsites.net'이 (가) 'a11aaa11-1a5c-484a-b1d6-86c298e8f250'응용 프로그램에 대해 구성된 회신 주소와 일치하지 않습니다. 세부 정보 : 지정되지 않았 음

로그인 버튼을 클릭 할 때마다 오류가 반환됩니다 (사용자는 더 이상 로그인하라는 메시지가 표시되지 않습니다). 그것은 결코 토큰을 검색하지 못했습니다. 전체 인증 URL은 다음과 같습니다 내가 잘못 뭐하는 거지

https://login.windows.net/mydomain.onmicrosoft.com/oauth2/authorize?response_type=token&client_id=a11aaa11-484a-b1d6-86c298e8f250&redirect_uri=https%3A%2F%2Fmywebapp.azurewebsites.net&resource=https%3A%2F%2Fgraph.microsoft.com&state=982599964&nonce=3994725115

? 웹 앱의 호스트 이름 (리디렉션 URI)이 앱 등록을 호스팅하는 Azure AD 임차인의 도메인과 일치하지 않기 때문에 문제가 실제로 발생할 수 있습니까? 그렇다면 Office 365 또는 Exchange Online이없는 웹 응용 프로그램을 호스팅하는 Azure 구독에서 Exchange Online에 사용 권한을 부여하려면 어떻게해야합니까? Office 365 테넌트에 웹 응용 프로그램을 호스팅 할 수 있도록 Azure 구독을 추가해야합니까 ??

답변

1

앱 매니페스트에서 replyUrls 중 하나로 https://myapp.azurewebsites.net/MessageRead.html을 사용했음을 발견했습니다. 아래는 사용자의 동의를 얻기 위해 사용하고있는 URL입니다.

https://login.windows.net/mydomain.onmicrosoft.com/oauth2/authorize?response_type=token&client_id=a11aaa11-484a-b1d6-86c298e8f250&redirect_uri=https%3A%2F%2Fmywebapp.azurewebsites.net&resource=https%3A%2F%2Fgraph.microsoft.com&state=982599964&nonce=3994725115.

위의 URL을 준수하면 redirect_urihttps://myapp.azurewebsites.net으로 언급했습니다. 하지만 redirect_uri는 앱 매니페스트에서 언급 한 replyUrls 중 하나 이상과 일치해야합니다.

인증 URL에 https://myapp.azurewebsites.nethttps://myapp.azurewebsites.net/MessageRead.html으로 대체하십시오.

아래 URL에서 직접 업데이트 할 수 있습니다. 원하실 경우 아래 url에서 직접 업데이트 할 수 있습니다.

https://login.windows.net/mydomain.onmicrosoft.com/oauth2/authorize?response_type=token&client_id=a11aaa11-484a-b1d6-86c298e8f250&redirect_uri=https%3A%2F%2Fmywebapp.azurewebsites.net%2FMessageRead.html&resource=https%3A%2F%2Fgraph.microsoft.com&state=982599964&nonce=3994725115

+0

불행하게도 나는 URL을 변경할 수 없습니다 - 그 사무실 JS-도우미에 의해 내부적으로 처리합니다. 방금 예외 추적에서 인증 대화 상자의 깊은 부분에서 URL이 오류로 반환 된 것으로 나타났습니다 –

+0

앱 매니페스트에서 replyUrl 값을 https://myapp.azurewebsite.net으로 업데이트하고 확인 하시겠습니까? – MK446

+0

URL을 /MessageRead.html없이 사용하면 루트 페이지가 없어 팝업 인증자가 빈 페이지로 열림 –