gpt4 book ai didi

authentication - Azure Google 身份验证显示错误 :disallowed_useragent

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

我最近遇到了这个错误Error Message

我认为这是由于 Google Oauth 发生了这种变化:https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html .

我正在使用 Azure 身份验证服务对我用 Xamarin Forms (C#) 编写的 iOS 应用程序进行身份验证。

代码请求 Azure 身份验证服务:

var window = UIKit.UIApplication.SharedApplication.KeyWindow;
var root = window.RootViewController;
if(root != null)
{
var current = root;
while(current.PresentedViewController != null)
{
current = current.PresentedViewController;
}

var user = await AzureService.Instance.Client.LoginAsync(window.RootViewController, MobileServiceAuthenticationProvider.Google, new Dictionary<string, string>() { { "access_type", "offline" } });
return user;
}

网址请求是:
using(var client = new HttpClient())
{
const string url = "https://www.googleapis.com/oauth2/v3/userinfo?alt=json&suppress_webview_warning=true";
client.DefaultRequestHeaders.Add("Authorization", token);
var json = client.GetStringAsync(url).Result;
var profile = JsonConvert.DeserializeObject<GoogleUserProfile>(json);
return profile;
}

但是它仍然向我显示错误:
谷歌的 Azure 身份验证设置正确,因为直到最近我一直使用这个设置一个多月。任何人都有同样的问题或任何想法如何解决这个问题?

最佳答案

简短的版本是谷歌将 OAuth 协议(protocol)更改为“更安全”。我们目前正在对各种客户端 SDK 进行更新,以启用新的更安全的方法,该方法仅影响服务器流。

要做的事情的简短版本是实现客户端流。将 Google SDK 集成到您的应用中,然后将收到的 token 发送到后端。由于您在 Xamarin.Forms 中,这将意味着在特定于平台的代码中实现某些内容。

抱歉,我没有这方面的例子。我已经完成了 FB auth 和 AAD auth,但目前还没有完成 Google auth。然而,概念是相同的。您需要在特定于平台的代码中执行 Google 身份验证,然后使用类似于以下内容的方式调用 ZUMO 身份验证端点:

public async Task<MobileServiceUser> LoginAsync(MobileServiceClient client)
{
// Call the code to do the Google Auth via the Google SDK
var accessToken = await LoginGoogleAsync();
// Construct and call the client-flow ZUMO auth
var zumoPayload = new JObject();
zumoPayload["access_token"] = accessToken;
return await client.LoginAsync("google", zumoPayload);
}

每个 Azure 移动应用 SDK 的下一个版本都将包含 Google OAuth 更改。不幸的是,我没有这些版本的时间表。

关于authentication - Azure Google 身份验证显示错误 :disallowed_useragent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40553074/

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