【发布时间】:2016-11-11 17:19:05
【问题描述】:
我最近遇到了这个错误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;
}
但是它仍然向我显示错误: Google 的 Azure 身份验证设置正确,因为直到最近我一直使用此设置一个多月。有人遇到同样的问题或知道如何解决这个问题吗?
【问题讨论】:
-
我正在处理同样的问题,我得到的所有建议都是用原生 iOS 代码编写的。我正在处理前端带有 JS 和 HTML 的传统 Ruby on Rails 应用程序。我没有用 JS 做 OAuth。我对 Ruby 很感兴趣,但我认为这种变化基本上扼杀了我的独立应用程序。
标签: authentication xamarin.forms google-oauth azure-mobile-services