ユーザーがアプリのログインとパスワードを作成する必要がないように、oauth2 プロトコルを使用して Android アプリケーションのユーザーを認証したいと考えています。
そのために、次のチュートリアルに従います: http://android-developers.blogspot.fr/2013/01/verifying-back-end-calls-from-android.html
Google Play サービス SDK サンプル (AndroidSDK\extras\google\google_play_services\samples\auth 内) をインポートし、スコープ値を変更しました。
ただし、認証トークンを取得できません...GoogleコンソールAPIを正しく構成していますが。
getToken メソッドを呼び出す関数は次のとおりです。
protected String fetchToken() throws IOException {
try {
return GoogleAuthUtil.getToken(mActivity, mEmail, mScope);
} catch (GooglePlayServicesAvailabilityException playEx) {
// GooglePlayServices.apk is either old, disabled, or not present.
mActivity.showErrorDialog(playEx.getConnectionStatusCode());
} catch (UserRecoverableAuthException userRecoverableException) {
// Unable to authenticate, but the user can fix this.
// Forward the user to the appropriate activity.
mActivity.startActivityForResult(userRecoverableException.getIntent(), mRequestCode);
} catch (GoogleAuthException fatalException) {
onError("Unrecoverable error " + fatalException.getMessage(), fatalException);
}
return null;
}
そして、ここに私のスコープがあります:audience:server:client_id:MY_CLIENT_ID.apps.googleusercontent.com
それを試すと、次の例外が発生します。
08-16 17:22:08.471: E/TokenInfoTask(16546): Exception:
08-16 17:22:08.471: E/TokenInfoTask(16546): com.google.android.gms.auth.GoogleAuthException: Unknown
08-16 17:22:08.471: E/TokenInfoTask(16546): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)