문제

액세스 토큰을 가져 와서 서버에 보낼 필요가 있습니다.해당 액세스 토큰 서버는 이름, 프로필 사진 및 이메일과 같은 모든 사용자 세부 정보를 가져와야합니다.

scopes.plus_login scopes.plus_me 를 사용하여 액세스 토큰을 얻을 수 있지만 액세스 토큰 서버가 사용자 이메일을 가져올 수 없습니다.

여기에 내 코드가 있습니다 :

@Override
public void onConnected(Bundle arg0) {
    mSignInClicked = false;


    AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            String token = null;
            String scope = "oauth2:" + Scopes.PLUS_LOGIN + " " + Scopes.PLUS_ME;
            try {
                token = GoogleAuthUtil.getToken(
                        getApplicationContext(),
                        Plus.AccountApi.getAccountName(mGoogleApiClient),
                        scope);
                appUser.setToken(token);
            } catch (IOException transientEx) {
                // Network or server error, try later
                Log.e(TAG, transientEx.toString());
            } catch (UserRecoverableAuthException e) {
                // Recover (with e.getIntent())                
            } catch (GoogleAuthException authEx) {
                // The call is not ever expected to succeed
                // assuming you have already verified that 
                // Google Play services is installed.
                Log.e(TAG, authEx.toString());
            }

            return token;
        }

        @Override
        protected void onPostExecute(String token) {
            Log.i(TAG, "Access token retrieved:" + appUser.getToken());
            // Get user's information
        }

    };


}
.

아무도이 문제를 해결하는 방법을 알고 있습니까?

도움이 되었습니까?

해결책

범위가 누락되었습니다

https://www.googleapis.com/auth/userinfo.email  
.

다른 범위를 테스트했으며 사용자이 전자 메일을 반환하는 것으로 나타났습니다.다른 범위를 테스트 할 수 있으며 여기에서 반환하는 내용을 테스트 할 수 있습니다. 사람들 : 얻기 ...에

참고 : Android 프로그래머가 아니므로 Android로 해당 범위를 요청하는 방법을 찾는 방법을 더 잘 알 수 있습니다.나는보고 있지만 그것을 찾을 수 없었습니다.

범위가 https://developers.google.com/+ / API / OAuth # 이메일

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top