22

Android、Google認証の問題があります( .GoogleAuthException: Unknown while doing Google SSO. - no Answerに似ています):

09-29 00:04:38.328: W/System.err(15623): com.google.android.gms.auth.GoogleAuthException: Unknown
09-29 00:04:38.328: W/System.err(15623):    at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)

次のコードを実行すると再現可能です。

String scopesString = Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE;
String scopes = "oauth2:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID + ":api_scope:" + scopesString;
OR
String scopes = "audience:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID;
Bundle appActivities = new Bundle();
appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "http://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity");
GoogleAuthUtil.getToken(activity,  accountName, scopes, appActivities);

以下にいくつかの注意事項を示します。

  1. GoogleAuthUtil.getToken(activity, accountName, "oauth2:" + scopesString) でアクセストークンを取得できます
  2. activity != null, client_id = 123456789.apps.googleusercontent.com, accountName は有効なメールです (アカウント ピッカーで選択)
  3. http://plus.google.com/u/0/appsのaccountName には、私のプロジェクトに関する記録があります: <Project Name> ------- アプリと購入活動--------あなたのサークル
  4. 私は持っているandroid.permission.GET_ACCOUNTS
  5. appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "") での同じ例外
  6. GoogleAuthUtil.getToken(activity, accountName, scopes) での同じ例外

解決した

  1. インストール済みアプリ (Android) とサービス 1 の 2 つのクライアント ID が必要です。ここではサービス 1 を使用する必要があります。
  2. 次に、UserRecoverableAuthException: NeedPermission を取得します。例外を処理する必要があります

つまり、このように:

} catch (UserRecoverableAuthException e) {
activity.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
}
4

4 に答える 4

0

私にとっては、gradleファイルの「applicationId」を変更したときに起こりました。API を有効にしたときに、開発者コンソールに同じ applicationId または packagename があることを確認してください。

于 2016-03-24T14:26:28.160 に答える
0

GoogleApiCliente に追加されたスコープを Plus.SCOPE_PLUS_LOGIN に変更します。これは私にとってはうまくいきます。

googleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API)
        .addScope(Plus.SCOPE_PLUS_LOGIN)
        .build();
于 2015-11-05T13:13:46.120 に答える
0

リリース キーストアを使用して SHA1 ハッシュを登録したため、不明なエラーが発生していました。デバッグ キーストアを使用して新しいアプリを登録すると、問題が解決しました。

于 2015-11-04T11:02:29.200 に答える