【发布时间】:2016-03-15 09:08:32
【问题描述】:
我需要注册我的应用才能使用 Outlook 日历 API。我在这里创建了应用程序:https://apps.dev.microsoft.com。我有应用程序 ID 和重定向 URI。然后我使用以下方法获取令牌:
[self.context acquireTokenWithResource:resourceID
clientId:clientID
redirectUri:redirectURI
completionBlock:^(ADAuthenticationResult *result) {
if (result.status !=AD_SUCCEEDED){
completion(result.error);
}
else{
self.accessToken = result.accessToken;
self.refreshToken = result.tokenCacheStoreItem.refreshToken;
self.familyName = result.tokenCacheStoreItem.userInformation.familyName;
self.givenName = result.tokenCacheStoreItem.userInformation.givenName;
self.userID = result.tokenCacheStoreItem.userInformation.userId;
completion(nil);
}
}];
得到了这个错误:
Error with code: 15 Domain: ADAuthenticationErrorDomain ProtocolCode:unauthorized_client Details:AADSTS70001: Application '***' is not supported for this API version.
Trace ID: c5286e11-9fa9-4ddd-96a4-a29ddd6b416c
Correlation ID: c608d556-729b-4cad-80be-24d85f5558d4
Timestamp: 2016-03-14 13:05:11Z. Inner error details: Error Domain=ADAuthenticationErrorDomain Code=15 "The operation couldn’t be completed. (ADAuthenticationErrorDomain error 15.)"
请帮我正确注册我的应用
更新: @dstrockis 帮助解决了这个问题。但现在我还有一个: 还有https://cocoapods.org/pods/ADALiOS是使用方法
[authContext acquireTokenWithResource:resourceId
clientId:clientId
redirectUri:redirectUri
completionBlock:^(ADAuthenticationResult *result) {
if (AD_SUCCEEDED != result.status){
// display error on the screen
[self showError:result.error.errorDetails];
}
else{
completionBlock(result.accessToken);
}
}];
但 ADALiOS 库,3.0.0-pre3 不包含此方法。我试过用
- (void)acquireTokenWithScopes:(NSArray*)scopes
additionalScopes:(NSArray*)additionalScopes
clientId:(NSString*)clientId
redirectUri:(NSURL*)redirectUri
identifier:(ADUserIdentifier*)identifier
promptBehavior:(ADPromptBehavior)promptBehavior
completionBlock:(ADAuthenticationCallback)completionBlock;
我收到以下错误:“代码错误:17 域:ADAuthenticationErrorDomain ProtocolCode:(null) 详细信息:应用程序没有当前的 ViewController。内部错误详细信息:错误域 = ADAuthenticationErrorDomain 代码 = 17“操作无法' t 完成。 (ADAuthenticationErrorDomain 错误 17.)"".
【问题讨论】:
-
这是正确的使用方法。我会看看我是否可以让我们的 iOS 人员评论那个特定的错误。您确实需要在 ViewController 的上下文中调用该方法,以便 adal 可以弹出 Web 视图来执行身份验证。
-
@dstrockis,我在我的视图控制器中调用了它,在 ViewDidLoad 方法中以前的方法“acquireTokenWithResource”我也在那里调用并显示了授权控制器
-
@dstrockis 你碰巧发现了关于这个问题的任何其他信息吗?这实际上是一个漫长的过程,所以如果您或您的 iOS 人员可以提供帮助,我们将不胜感激:)
标签: azure authentication azure-active-directory adal