2016-08-08 4 views
3

그러나 X 박스 하나에 내가 오류가 점점 오전, 윈도우 10 데스크톱/모바일에서 실행할 때이 코드는 내 UWP 응용 프로그램에서 잘 작동 :Google 로그인 문제 - GoogleWebAuthorizationBroker.AuthorizeAsync

내 C# 코드 :

  1. 클릭을 구글 로그인에
  2. 구글 로그인 SCR BTN : 여기
    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; 
    

    이 일어나고있는 단계입니다 EEN은 여기

  3. 로그인 창 응용 프로그램
  4. 오류에 대한 권한을 승인하는 나에게 묻는다 내 구글 계정에 로그인 할 수 있습니다
  5. 를 어떻게됩니까로드 : 나는의 Oauth 토큰을 얻을 다음과 같은 오류 메시지가 얻을 결코 : 오류 : "성공", 설명 : "WebAuthenticationBroker가 코드 또는 오류를 반환하지 않았습니다. 세부 : 0 "열린 우리당" "

이 문제를 가지고있는 하나입니다

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

내가 잘못하고있는 무슨에 어떤 생각

+1

[WebAuthenticationBroker] (https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.security.authentication.web.webauthenticationbroker.aspx) 클래스를 사용하여 인증을 구현하려고 시도 했습니까? 방법? 이 API는이 클래스를 사용하지만 인증 코드를 가져 오지 못했습니다. –

답변

1

프랭클린이 제안한 것과 같이 좋은 오래된 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(); 
     }