【问题标题】:Azure App Services AuthenticationAzure 应用服务身份验证
【发布时间】:2015-12-16 16:57:23
【问题描述】:

是否有人能够使用 Azure 应用服务解决身份验证问题?

由于某种奇怪的原因,它不再像以前在移动服务中那样处理刷新令牌,我现在缓存的令牌会在 1 小时后过期,这是没用的。

这是一个 C# UWP 应用程序,我使用 Microsoft 帐户作为登录名,有人告诉我使用 OneDrive API 登录并检索令牌,然后使用它登录到应用程序服务,这不起作用对我来说,也会出现“您无权访问该目录”之类的错误。

感谢任何帮助。

【问题讨论】:

  • 登录令牌 1 小时到期是一个已知问题,正在修复中。如果您可以提供有关“您无权访问目录”问题的更多信息,我们可能有助于找到解决方法。当您收到此错误时,您能否提供 HTTP 跟踪?另外,尝试在管理门户中为您的应用打开应用程序日志记录,看看是否有任何有趣的警告/错误消息。
  • 是OneDrive SDK还是移动应用客户端抛出“您没有权限访问目录”?留言?
  • 一位菲利普在 MSDN 上的帖子中回答了这个问题,猜是你哈哈。但基本上,我在我的 JObject 中使用“authentcationToken”作为键,我应该使用“access_token”,它可以工作,现在允许我使用从 OneDrive 获得的令牌登录到应用服务。但是我想指出,该文档明确表示对 Microsoft 帐户使用“authenticationToken”而不是“access_token”,这似乎是错误的,并且是导致权限问题的原因。最近,与 MobileServices/AppServices 相关的文档非常混乱。
  • 另外,我很高兴听到 1 小时到期是一个“问题”并且正在修复中。我实际上为此使用了一张 Azure 支持票,所以在你们解决问题之前,我似乎不会得到解决方案。你能给我更多关于这个问题的信息吗?它是孤立的还是每个人都经历过?任何 ETA 修复?
  • 是的,“authenticationToken”曾经是旧版实时 SDK 中唯一暴露的。所有文档都需要更新以显示“access_token”,据我所知,这是 OneDrive SDK 为您提供的所有内容。

标签: c# azure azure-web-app-service azure-mobile-services windows-10-universal


【解决方案1】:

App Service Mobile 的解决方案,MobileService 的更新。现在应该有一个solution

这里复制的代码是:

async Task<string> GetDataAsync()
{
try
{
    return await App.MobileService.InvokeApiAsync<string>("values");
}
catch (MobileServiceInvalidOperationException e)
{
    if (e.Response.StatusCode != HttpStatusCode.Unauthorized)
    {
        throw;
    }
}

// Calling /.auth/refresh will update the tokens in the token store
// and will also return a new mobile authentication token.
JObject refreshJson = (JObject)await App.MobileService.InvokeApiAsync(
    "/.auth/refresh",
    HttpMethod.Get,
    null);

string newToken = refreshJson["authenticationToken"].Value<string>();
App.MobileService.CurrentUser.MobileServiceAuthenticationToken
    = newToken;
return await App.MobileService.InvokeApiAsync<string>("values");
}

希望它能节省一些时间!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-26
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 2016-07-26
    • 1970-01-01
    • 2020-06-10
    • 2017-07-26
    相关资源
    最近更新 更多