我使用Google Plus SDK登錄。如果是succces,我請求用戶的訪問令牌谷歌用戶信息只給出從Android谷歌訪問令牌的ID加
String scope = "oauth2:" + Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE;
String token = GoogleAuthUtil.getToken(context, mPlusClient.getAccountName(), scope);
它的工作原理和我得到的令牌,但如果我嘗試它(我將發送到服務器的令牌),我得到這個:
https://www.googleapis.com/oauth2/v1/userinfo?access_token=ya29.xxx ...
{ id: "1060xxxxxxxxxxxxxx" }
其他數據,例如電子郵件,姓名等?
我嘗試另一個soution和我添加的服務器部分,範圍:
String CLIENT_ID = "abc123.apps.googleusercontent.com";
List<String> SCOPES = Arrays.asList(new String[]{
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/plus.me"
});
String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID, TextUtils.join(" ", SCOPES));
但在這種情況下,我總是得到錯誤:
com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)