Google Xbox One C# 上的登录问题 - GoogleWebAuthorizationBroker.AuthorizeAsync
Google login issues on Xbox One C# - GoogleWebAuthorizationBroker.AuthorizeAsync
当 运行 在 Windows 10 desktop/mobile 上时,此代码在我的 UWP 应用程序中工作正常,但是在 Xbox One 上我收到错误:
我的 C# 代码:
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new Uri("ms-appx:///Assets/client_secrets.json"),
new[] { "https://www.googleapis.com/auth/plus.profile.emails.read" },
"user",
CancellationToken.None);
return credential.Token.AccessToken;
以下是正在发生的步骤:
- 点击google登录按钮
- google 正在加载登录屏幕
- 我可以登录我的 google 帐户
- 登录 windows 要求我为应用程序授权权限
- 此处发生错误:我从未获得 Oauth 令牌并收到以下错误消息:
错误:"Success"、说明:"The WebAuthenticationBroker didn't return a code or an error. Details:0"、URI:“”
有人遇到这个问题吗?
我的 project.json 文件:
{
"dependencies": {
"Google.Apis": "1.15.0",
"Google.Apis.Auth": "1.15.0",
"Google.Apis.Core": "1.15.0",
"Microsoft.ApplicationInsights": "2.1.0",
"Microsoft.ApplicationInsights.PersistenceChannel": "1.2.3",
"Microsoft.ApplicationInsights.WindowsApps": "1.1.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"Microsoft.Xaml.Behaviors.Uwp.Managed": "1.1.0",
"MvvmLightLibs": "5.3.0",
"Newtonsoft.Json": "9.0.1",
"NotificationsExtensions.Win10": "14295.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
知道我做错了什么吗?
就像富兰克林建议的那样,我选择了一个很好的旧 WebAuthenticationBroker,如果其他人感兴趣的话,这里是一段代码:
String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id="
+ Uri.EscapeDataString("ABC-DECF1234.apps.googleusercontent.com")
+ "&redirect_uri=" + Uri.EscapeDataString("urn:ietf:wg:oauth:2.0:oob")
+ "&response_type=code&scope=" + Uri.EscapeDataString("https://www.googleapis.com/auth/plus.profile.emails.read");
Uri StartUri = new Uri(GoogleURL);
Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");
WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.UseTitle, StartUri, EndUri);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
return WebAuthenticationResult.ResponseData.ToString();
}
当 运行 在 Windows 10 desktop/mobile 上时,此代码在我的 UWP 应用程序中工作正常,但是在 Xbox One 上我收到错误:
我的 C# 代码:
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new Uri("ms-appx:///Assets/client_secrets.json"),
new[] { "https://www.googleapis.com/auth/plus.profile.emails.read" },
"user",
CancellationToken.None);
return credential.Token.AccessToken;
以下是正在发生的步骤:
- 点击google登录按钮
- google 正在加载登录屏幕
- 我可以登录我的 google 帐户
- 登录 windows 要求我为应用程序授权权限
- 此处发生错误:我从未获得 Oauth 令牌并收到以下错误消息: 错误:"Success"、说明:"The WebAuthenticationBroker didn't return a code or an error. Details:0"、URI:“”
有人遇到这个问题吗?
我的 project.json 文件:
{
"dependencies": {
"Google.Apis": "1.15.0",
"Google.Apis.Auth": "1.15.0",
"Google.Apis.Core": "1.15.0",
"Microsoft.ApplicationInsights": "2.1.0",
"Microsoft.ApplicationInsights.PersistenceChannel": "1.2.3",
"Microsoft.ApplicationInsights.WindowsApps": "1.1.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"Microsoft.Xaml.Behaviors.Uwp.Managed": "1.1.0",
"MvvmLightLibs": "5.3.0",
"Newtonsoft.Json": "9.0.1",
"NotificationsExtensions.Win10": "14295.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
知道我做错了什么吗?
就像富兰克林建议的那样,我选择了一个很好的旧 WebAuthenticationBroker,如果其他人感兴趣的话,这里是一段代码:
String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id="
+ Uri.EscapeDataString("ABC-DECF1234.apps.googleusercontent.com")
+ "&redirect_uri=" + Uri.EscapeDataString("urn:ietf:wg:oauth:2.0:oob")
+ "&response_type=code&scope=" + Uri.EscapeDataString("https://www.googleapis.com/auth/plus.profile.emails.read");
Uri StartUri = new Uri(GoogleURL);
Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");
WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.UseTitle, StartUri, EndUri);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
return WebAuthenticationResult.ResponseData.ToString();
}