简体   繁体   English

Azure App Services身份验证

[英]Azure App Services Authentication

Has anyone been able to figure out authentication using Azure App Services? 有谁能够使用Azure App Services找出身份验证?

For some strange reason it is no longer handling refresh tokens like it used to in Mobile Services, the token I'm now caching expires in 1 hour, this is useless. 由于一些奇怪的原因,它不再像在移动服务中那样处理刷新令牌,我现在正在缓存的令牌在1小时后过期,这是没有用的。

It's a C# UWP app, I'm using Microsoft Account as the login, I've been told to use the OneDrive API to login and retrieve the token and then use that to login to App Services, that doesn't work for me either, with an error like "you do not have permission to access the directory". 这是一个C#UWP应用程序,我使用Microsoft帐户作为登录名,有人告诉我使用OneDrive API登录并检索令牌,然后使用该令牌登录到App Services,这对我也不起作用,并显示类似“您无权访问目录”的错误。

Any help is appreciated. 任何帮助表示赞赏。

A solution for App Service Mobile, the update to MobileService. App Service Mobile的解决方案,MobileService的更新。 There should now be a solution 现在应该有一个解决方案

The code replicated here is: 这里复制的代码是:

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

Hope it saves somebody time ! 希望它可以节省一些时间!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM