2014-01-13 6 views
3

내 목표는 서버 측 작업없이 사용자의 기본 프로필 정보 (이름, 성 등)를 얻는 것입니다. UI에서 Google+ 로그인 버튼을 사용하고 싶지 않습니다.GoogleAuthUtil.getToken com.google.android.gms.auth.GoogleAuthException : Unknown

아무런 문제없이 사용자의 이메일을받을 수 있습니다. 그래서 다음 단계는 여기에 프로파일을 가져 액세스 토큰을 얻는 것은 나는 "COM을 가지고, 내 코드

String token = null; 
    try { 
     token = GoogleAuthUtil.getToken(getApplicationContext(), email, SCOPE); 
    } catch (final UserRecoverableAuthException e) { 
     startActivityForResult(e.getIntent(), REQUEST_CODE_AUTH_GOOGLE_ACCOUNT); 
    } catch (IOException e) { 
     Log.e(TAG, e.toString()); 
    } catch (GoogleAuthException e) { 
     Log.e(TAG, e.toString()); 
    } 

내가 내 응용 프로그램을 실행할 때 나는

private static final String SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile"; 

범위

을 정의했다. google.android.gms.auth.GoogleAuthException : 알 수없는 "예외입니다. 또한 Scope.PLUS_LOGIN, Scope.PLUG_PROFILE과 같은 다른 범위를 시도했습니다. 그러나 그들 모두 나에게 같은 예외를 주었다.

Btw, Google API 콘솔에서 이미 클라이언트 ID를 설정했습니다.

2 일 동안 계속되었습니다. 어떤 도움이라도 대단히 감사 할 것입니다.

답변

1
+0

는이 버그에 저를 도와주세요 수 http://stackoverflow.com/questions/21445265/google :

scopes.add(AnalyticsScopes.ANALYTICS_READONLY); credential = GoogleAccountCredential.usingOAuth2(this, scopes); if (TextUtils.isEmpty(appPreferences.getUserName())) { try { startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.gps_missing), Toast.LENGTH_LONG).show(); return; } } 

여기 내 소스 파일을 살펴보십시오 : 그건 내가 그것을 할 방법입니다 - 좌표 - 인증 –

관련 문제