2016-08-08 5 views
3

Dieser Code funktioniert in meinem UWP App gut, wenn auf Windows 10 Desktop/Mobile ausgeführt wird, aber auf Xbox One Ich erhalte eine Fehlermeldung:Google Anmeldung Probleme auf Xbox One C# - GoogleWebAuthorizationBroker.AuthorizeAsync

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; 

Hier sind die Schritte, die passiert sind:

  1. Klicken Sie auf google Login BTN
  2. google Login scr een ist loading
  3. kann ich mein Google-Konto einloggen in
  4. Das Login-Fenster fragt mich, für die App-Berechtigungen zu autorisieren passiert
  5. Fehler hier: Ich habe nie die OAuth-Token und die folgende Fehlermeldung: Fehler: "Success", Beschreibung: "Der WebAuthenticationBroker gab keinen Code oder Fehler zurück. Details: 0" , Uri: ""

Ist jemand dieses Problem mit

Meine project.json-Datei:?

{ 
    "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": {} 
    } 
} 

Jede Idee, was ich falsch mache

+1

Haben Sie versucht, die Klasse [WebAuthenticationBroker] (https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.security.authentication.web.webauthenticationbroker.aspx) zu verwenden, um die Authentifizierung zu implementieren verarbeiten? Sieht so aus, als ob diese API diese Klasse verwendet, aber keinen Authentifizierungscode erhalten kann –

Antwort

1

Wie Franklin vorgeschlagen Ich ging mit einem guten alten WebAuthenticationBroker, hier das Stück Code, wenn jemand anderes interessiert ist:

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(); 
     } 
Verwandte Themen