authentication에 대해 사용자의 Google 계정 user_id
에 액세스하고 싶지만 AccountManager
에는이 점에 대한 언급이 없습니다.Google 계정 user_id에 어떻게 액세스합니까?
내 앱에서 user_id
을 어떻게 요청할 수 있나요?
authentication에 대해 사용자의 Google 계정 user_id
에 액세스하고 싶지만 AccountManager
에는이 점에 대한 언급이 없습니다.Google 계정 user_id에 어떻게 액세스합니까?
내 앱에서 user_id
을 어떻게 요청할 수 있나요?
이제 Google Play Services을 사용할 수 있으므로이를 사용하여 https://www.googleapis.com/auth/userinfo.profile
범위에 액세스 할 수있는 사용자 권한을 요청하고 그 결과 액세스 토큰을 사용하여 https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken}
에게 사용자 ID를 요청합니다.
Google Play 서비스가 출시 될 때까지 Android 계정 관리자의 getAuthToken API를 사용해야합니다. 구글의 AccountManager example for the Tasks API을 https://stackoverflow.com/a/10988589/313790
체크 아웃 :
여기 당신이 access_token
을 얻기 위해 getAuthToken을 사용하는 방법의 예입니다.
당신이 액세스 토큰이 있으면 대신 작업 라이브러리를 사용하여, 당신은 다음, this example에 같은 Userinfo
객체를 요청하는 구글-API - 자바 클라이언트의 oauth2 library를 사용
Oauth2 oauth2 = new Oauth2.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("Google-OAuth2Sample/1.0").build();
Userinfo userinfo = oauth2.userinfo().get().execute();
String userId = userinfo.getId();
은'사용자 정보입니다 ? access_token = {accessToken}'요청은 어딘가에 문서화되어 있습니까? –
userinfo에 대한 설명서는 다음 페이지에서 제공됩니다. https://developers.google.com/accounts/docs/OAuth2Login#userinfocall –
[noticed] (https://developers.google.com/android/google-play-services/))'참고 : Google Play 서비스가 출시되지는 않았지만 기대되는 사항에 대한 간략한 개요를 제공하고자합니다. 'API가 아직 제공되지 않았거나 베타 상태에 있다는 뜻입니까? –