My c# code:
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;
Here are the steps that are happening:
>click on Google login btn
>Google login interface is now Loading
>I can log in to my Google account
>The login window asks me to authorize permissions for the application
>An error occurred here: I never got an Oauth token and received the following error message:< br>Error: “Success”, description: “WebAuthenticationBroker did not return a code or error. Details: 0”, Uri: “”
Does anyone have this problem?
My project.json file:
{
"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": {}
}
}
Thoughts on what I did wrong?
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();
}
When running on a Windows 10 desktop/mobile device, this code works fine in my UWP app , But on Xbox One I receive an error:
My c# code:
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;
Here are the steps that are happening:
>Click on Google to log in btn
>The Google login interface is loading
>I can log in to my Google account
>The login window asks me to authorize the permission of the application
>Happens here Error: I have never obtained an Oauth token and received the following error message:
Error: “Success”, Description: “WebAuthenticationBroker did not return a code or error. Details: 0”, Uri: “”
< p>Does anyone have this problem?
My project.json file:
{
"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": {}
}
}
Thoughts on what I did wrong?
As Franklin proposed, I chose a good old WebAuthenticationBroker, if anyone else is interested, here is a piece of code:
< /p>
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();
}