gpt4 book ai didi

cordova - Azure Active Directory/.auth/refresh 发出的刷新请求失败,因为在 token 存储中找不到刷新 token

转载 作者:行者123 更新时间:2023-12-03 04:27:07 25 4
gpt4 key购买 nike

我有一个 Cordova 应用程序,它使用 JS 客户端 SDK 成功通过 Azure Active Directory 进行身份验证。我已按照 CGillum 帖子中的说明对我的 Azure 网站进行了更改。这成功地为我提供了一个可以与 Microsoft Graph 一起使用的 token ,并且在调用 /.auth/me 时它返回一个刷新 token 。

但是,当我尝试调用 /.auth/refresh 时,我收到 403 错误,并且日志显示以下内容。

2017-02-01T16:00:54  PID[8648] Warning     The refresh request issued
by sid... failed because no refresh tokens were found in the token
store.
2017-02-01T16:00:54 PID[8648] Information Sending response: 403.80 Forbidden

我在 Azure 网站设置中打开了 token 存储。我还注意到,如果我调用 /.auth/me,它不再返回刷新 token 。这可能是有意的行为,因为我知道某些提供商只会为您提供一次刷新 token (但不确定 AAD)。

  public getAccessTokenFromRefreshTokenFromAppService(): Promise<any> {
return new Promise<boolean>((resolve, reject) => {
let apiUrl = Resources.azureMobileClientUrl + '/.auth/refresh';
var headers = new Headers();
headers.append('X-ZUMO-AUTH', this.azureService.mobileServiceClient.currentUser.mobileServiceAuthenticationToken);
return this.http.get(apiUrl, { headers: headers })
.map(res => res.json())
.subscribe(data => {
console.log('Get Refresh Token - ', data);
let token = data.authenticationToken;

resolve(data);
},
error => {
reject(error);
},
() => {
});
});

}

最佳答案

如果我没有误解您的要求,您希望在 Azure Web 应用程序/移动应用程序中启用刷新 token ,如 http://cgillum.tech/2016/03/07/app-service-token-store/ 中所述。作者:cgillum。

正如他所提到的,如果您计划通过 AAD IDP 启用此功能,我们需要在我们的应用服务上进行一些额外的配置。您可以引用http://cgillum.tech/2016/03/25/app-service-auth-aad-graph-api/了解更多详情。

一般来说,启用它有两个步骤:

  1. 在 AAD 应用程序中生成 key ,并同意 Windows Azure Active Directory 的两个权限:读取目录数据读取目录数据:
    enter image description here

  2. 通过 REST API 更新应用服务身份验证配置

    • 在应用服务的身份验证/授权部分设置上面生成的 key 。
      enter image description here

    • 进入 Azure 资源浏览器
      enter image description here
      additionalLoginParams 设置为 ["response_type=code id_token", "resource=https://graph.windows.net"]
      enter image description here

关于cordova - Azure Active Directory/.auth/refresh 发出的刷新请求失败,因为在 token 存储中找不到刷新 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41984443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com