2017-05-29 21 views
2

我試圖使用庫登錄到微軟的API中列出的資源。我的意圖是在我的日曆上閱讀和編寫任務。我使用下面的代碼來訪問接入代碼:ADAL圖書館 - 客戶端已請求訪問未在所要求的權限,可以在客戶端的應用程序註冊

func get365AcessToken() -> String { 
     let clientId = "bb5e40e8-1fcc-XXXXXXXXX" 
     let redirectUrl = "XXXXXXXXX-1fcc-47ac-b339-571a52d0f862://auth" 

     let authContext = ADAuthenticationContext.init(authority: "https://login.microsoftonline.com/common", error: nil) 
     authContext.acquireTokenWithResource("https://graph.windows.net", clientId: clientId, redirectUri: NSURL.init(string: redirectUrl)) { (result) in 
      print(result) 
      print(result.error.errorDetails) 
      print(result.accessToken) 
     } 
     authContext.parentController = self 

     return "" 
    } 

但我reveive此錯誤:

2017-05-29 13:05:26.473556 CRM & Sales[1174:988990] ADAL 2.3.0 iOS 10.2 [2017-05-29 16:05:26] ERROR: Error raised: (Domain: "ADOAuthServerErrorDomain" Code: AD_ERROR_SERVER_AUTHORIZATION_CODE ProtocolCode: "access_denied" Details: "AADSTS65005: Invalid resource. The client has requested access to a resource which is not listed in the requested permissions in the client's application registration. Client app ID: bb5e40e8-1fcc-47ac-XXXXXXXXX. Resource value from request: https://graph.windows.net. Resource app ID: 00000002-0000-0000-c000-000000000000. List of valid resources from app registration: 00000003-0000-0000-c000-000000000000. 

Trace ID: e2f4f866-1aa1-4fb6-b37e-9ae432174b00 

Correlation ID: af10d363-151a-452b-a6d2-a94cd6772ca4 

Timestamp: 2017-05-29 16:05:26Z" 

this is my settings

我能是做錯了什麼?

+0

你有沒有成功地運行示例iOS應用的https://libraries.io/github/microsoftgraph/ios-swift-connect-rest-sample –

+0

我不「噸試試這個! –

回答

2

該應用程序已被授予訪問權限與GUID 00000003-0000-0000-c000-000000000000資源。您請求已經GUID 00000002-0000-0000-c000-000000000000的資源。

你應該重新檢查你的應用程序的權限。

+0

你知道,這應該允許離開的Windows Azure Active Directory中添加? – Chirag