Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Token 使用Microsoft Graph时是否需要刷新访问令牌?如何刷新?_Token_Access Token_Microsoft Graph Api_Refresh Token - Fatal编程技术网

Token 使用Microsoft Graph时是否需要刷新访问令牌?如何刷新?

Token 使用Microsoft Graph时是否需要刷新访问令牌?如何刷新?,token,access-token,microsoft-graph-api,refresh-token,Token,Access Token,Microsoft Graph Api,Refresh Token,我正在为我的iOS应用程序使用Microsoft Graph SDK 我是否需要在访问令牌过期时手动刷新它 我说的访问令牌是: NXOAuth2AccountStore.sharedStore().accounts[0].accessToken 我已经测试过,即使accessToken过期,我仍然可以查询。在我第一次登录时,过期时间是3600秒。所以,我等了2个小时,测试以获得用户信息,再次事件,仍然可以得到它 我已转储“accessToken.hasExpired”和“accessToken.

我正在为我的iOS应用程序使用Microsoft Graph SDK

我是否需要在访问令牌过期时手动刷新它

我说的访问令牌是: NXOAuth2AccountStore.sharedStore().accounts[0].accessToken

我已经测试过,即使accessToken过期,我仍然可以查询。在我第一次登录时,过期时间是3600秒。所以,我等了2个小时,测试以获得用户信息,再次事件,仍然可以得到它

我已转储“accessToken.hasExpired”和“accessToken.expiresAt”以确保访问令牌已过期

谢谢

*更多详细信息*

我遵循以下示例:

我在Microsoft Graph上找不到有关刷新访问令牌的任何文档:
是的,在应用程序中使用Graph时,需要定期刷新令牌。更多详细文档可通过Azure AD的网站获得:

您正在使用的建议身份验证库包含刷新此令牌的方法:

@实现NXOAuth2AuthenticatorRefreshCallback


如果我还没有回答你的问题,你能更具体地说明你想要完成什么吗?您可以使用过期的令牌还是无法刷新旧令牌?

是的,在应用程序中使用Graph时需要定期刷新令牌。更多详细文档可通过Azure AD的网站获得:

您正在使用的建议身份验证库包含刷新此令牌的方法:

@实现NXOAuth2AuthenticatorRefreshCallback


如果我还没有回答你的问题,你能更具体地说明你想要完成什么吗?您可以使用过期的令牌还是无法刷新旧令牌?

需要刷新访问令牌时,请使用此代码。 这将作为graph sdk中提供的预定义代码的补丁,您可以从方法中提取令牌:

+(id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;

[MSGraphClient setAuthenticationProvider:AppDel.authentication.authProvider];

_graphClient = [MSGraphClient client];

NSMutableURLRequest * sampleReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://graph.microsoft.com/v1.0/me"]];

[_graphClient.authenticationProvider appendAuthenticationHeaders:sampleReq completion:^(NSMutableURLRequest *request, NSError *error){    
    if(error == nil)
    {

    }
    else
    {
        [self showToast:@"" message:@"Failure in refresh 0365 token"];
    }
}];

每当需要刷新访问令牌时,请使用此代码。 这将作为graph sdk中提供的预定义代码的补丁,您可以从方法中提取令牌:

+(id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;

[MSGraphClient setAuthenticationProvider:AppDel.authentication.authProvider];

_graphClient = [MSGraphClient client];

NSMutableURLRequest * sampleReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://graph.microsoft.com/v1.0/me"]];

[_graphClient.authenticationProvider appendAuthenticationHeaders:sampleReq completion:^(NSMutableURLRequest *request, NSError *error){    
    if(error == nil)
    {

    }
    else
    {
        [self showToast:@"" message:@"Failure in refresh 0365 token"];
    }
}];

嗨,凯特琳·巴勒斯,谢谢你的回答,我没有使用Microsoft Azure Active Directory。我使用Microsoft Graph,我在以下位置注册了一个应用程序:我只是好奇,因为我已经测试过,并且看到访问令牌已过期,但我仍然可以发送quest(例如,在日历中获取事件)。是的,Microsoft Graph使用Azure AD对用户进行身份验证(聚合身份验证:)。我将调查过期令牌问题,并在必要时为相关团队创建服务错误。您好Caitlin Bales,感谢您的回答我没有使用Microsoft Azure Active Directory。我使用Microsoft Graph,我在以下位置注册了一个应用程序:我只是好奇,因为我已经测试过,并且看到访问令牌已过期,但我仍然可以发送quest(例如,在日历中获取事件)。是的,Microsoft Graph使用Azure AD对用户进行身份验证(聚合身份验证:)。我将调查过期令牌问题,并在必要时为相关团队创建一个服务bug。