我使用MSGraph SDK iOS登录用户的Office365帐户。
我的最终目标是:
id_token,如Azure Active (AAD)端点文档中所述)使用示例应用程序,我能够登录用户,获得刷新令牌和用户详细信息(通过[[[[MSGraphClient client] me] request] getWithCompletion:...]),但我在任何地方都找不到id_token。
另外,我正在开发的安卓版本的应用程序正在使用https://outlook.office.com/api/v2.0作为SDK的基本URL,我也试图在iOS应用程序中从https://graph.microsoft.com/v1.0/中修改它。
在文档或示例应用程序中,我可能遗漏了一些显而易见或重要的东西,如果是这样的话,我很抱歉。
的问题是:如何使id_token在MSGraphSDK on iOS?
UPD:
下面是我使用的代码:
[NXOAuth2AuthenticationProvider setClientId:<clientId> scopes:@[@"https://graph.microsoft.com/Files.ReadWrite", @"https://graph.microsoft.com/Calendars.ReadWrite", @"openid"]];
[[NXOAuth2AuthenticationProvider sharedAuthProvider] loginWithViewController:nil completion:^(NSError *error) {
if (error) {
return;
}
NSArray *accounts = [[NXOAuth2AccountStore sharedStore] accountsWithAccountType:@"MSGraph"];
NXOAuth2Account *account = accounts.firstObject;
}];NXOAuth2Account没有任何可以与id_token连接的属性。问题是如何从NXOAuth2Client或MSGraphSDK框架中获取MSGraphSDK?
发布于 2018-03-26 20:36:00
只有在使用id_token流时才返回OpenID连接。要启用此功能,需要将openid添加到您请求的作用域列表中,并将id_token+code添加为您的response-type。
如果您希望获得一个更“完整”的email,也可以选择请求profile和id_token。
需要记住的另一个项目是,SDK没有提供令牌。它们是通过OAuth从Azure Active Directory获得的。SDK只接受您以前获得的令牌。
您可以使用几乎任何支持OAuth 2.0的库获得令牌,但我怀疑您正在查看的示例是使用NXOAuth2AuthenticationProvider。与…有关的东西:
[NXOAuth2AuthenticationProvider setClientId:<clientId>
scopes:@[@"https://graph.microsoft.com/Files.ReadWrite",
@"https://graph.microsoft.com/Calendars.ReadWrite"]];为了使用上面的示例获得id_token,可以添加openid作用域:
[NXOAuth2AuthenticationProvider setClientId:<clientId>
scopes:@[@"https://graph.microsoft.com/Files.ReadWrite",
@"https://graph.microsoft.com/Calendars.ReadWrite",
@"openid"]];https://stackoverflow.com/questions/49500076
复制相似问题