0

有没有人能够弄清楚使用 Azure 应用服务的身份验证?

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

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

任何帮助表示赞赏。

4

1 回答 1

1

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

这里复制的代码是:

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");
}

希望它能节省一些时间!

于 2016-05-24T12:34:33.320 回答