2016-07-27 13 views
0

Ich habe eine Android-Anwendung, wo ich Anmeldung mit Google in/out, deshalb habe ich die folgenden Google-API-Client verwenden:Muss ich 2 Google API-Client für Drive.API und Auth.GOOGLE_SIGN_IN_API erstellen?

 mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .enableAutoManage(this, this) 
      .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
      .addOnConnectionFailedListener(this) 
      .build(); 

Aber wenn ich will diesen Google-API-Client, wie dies für Antriebsverbindung einzurichten:

 mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .enableAutoManage(this, this) 
      .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
      .addApi(Drive.API) 
      .addOnConnectionFailedListener(this) 
      .build(); 

ich habe:

onConnectionFailed:ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null} 

Und dann ein Fehler, wenn ich signOut wollen verursachen GoogleApiClient nicht verbunden (aufgrund der connectionFa i)

Ich habe meine Konfigurationsdatei in meinem Ordner App, überprüfen Sie alle Informationen in Google Developer-Konsole, ich verstehe es nicht.

Antwort

0

Sie brauchen nur ein GoogleApiClient, das Wichtigste ist, unter Verwendung von requestScopes(new Scope(Scopes.DRIVE_APPFOLDER)) den Bereich zu definieren, das heißt

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
       .requestIdToken(getString(R.string.default_web_client_id)) 
       .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER)) 
       .requestEmail() 
       .build(); 

mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext()) 
       .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
       .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
       .addApi(Drive.API) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .build(); 
Verwandte Themen