AuthenticationContext的缓存授权令牌

时间:2017-04-04 00:57:48

标签: restful-authentication microsoft-graph azure-ad-graph-api

我是否可以缓存为租户生成的令牌,同时创建GraphServiceClient并重新使用它,如果是这样,令牌有效多长时间?是什么导致它到期? 我使用的代码使用IAuthenticationProvider并实现

public async Task AuthenticateRequestAsync(HttpRequestMessage request)
    {   
        AuthenticationContext authContext = new AuthenticationContext(url.ToString());
        ClientCredential creds = new ClientCredential(clientId, clientSecret);
        AuthenticationResult authResult = await authContext.AcquireTokenAsync("https://graph.microsoft.com", creds);
        request.Headers.Add("Authorization", "Bearer " + token);
    }

1 个答案:

答案 0 :(得分:0)

Azure Active Directory令牌生命周期记录为here

  

默认限制

     
      
  • 访问令牌生命周期      
        
    • 影响:访问令牌,ID令牌,SAML2令牌
    •   
    • 默认生命周期:1小时
    •   
  •   
  • 刷新令牌最长不活动时间      
        
    • 影响:刷新令牌
    •   
    • 默认生命周期:14天
    •   
  •   
  • 单因素刷新令牌最大年龄      
        
    • 影响:刷新令牌(适用于任何用户)
    •   
    • 默认生命周期:90天
    •   
  •   
  • 多因素刷新令牌最大年龄      
        
    • 影响:刷新令牌(适用于任何用户)
    •   
    • 默认生命周期:90天
    •   
  •   
  • 单因素会话令牌最大年龄      
        
    • 影响:会话令牌(持久性和非持久性)
    •   
    • 默认生命周期:直到被撤销
    •   
  •   
  • 多因素会话令牌最大年龄      
        
    • 影响:会话令牌(持久性和非持久性)
    •   
    • 默认生命周期:直到被撤销
    •   
  •   
相关问题