The order of Google Android Drive api does not work in the installed version

I developed an Android app that uses the GoogleDrive api,

When debugging or starting the debug version, the application works fine and correctly authenticates with the attached google..etc account. When I create the release version (with my signed keys) and install the apk file when I run, Googleapiclient cannot "connect" using the same google that works under debugging, giving me the message "Sign In Failed", after he will try to figure it out.

+3
source share
2 answers

was found https://developers.google.com/drive/android/get-started

I need to create a separate OAuth 2.0 client ID for the released version of my application using the sha1 key from my release key.

+3
source

First, you need to start one intention to get login credentials

if(mGoogleApiClient == null){ mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .enableAutoManage(this, this) .addScope(Drive.SCOPE_FILE) .addScope(Drive.SCOPE_APPFOLDER) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(AppIndex.API) .build(); } Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, DRIVE_SIGNIN_RESULT); 

No need to connect mGoogleApiClient here you can create a GoogleSignInResult object from the intent information you received in onActivityResult

  if (resultCode == RESULT_OK) { switch (requestCode) { case DRIVE_SIGNIN_RESULT: GoogleSignInResult signInResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(signInResult); break; } } 

Connect mGoogleApiClient now

  private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); mGoogleApiClient.connect(GoogleApiClient.SIGN_IN_MODE_OPTIONAL); } } 
0
source

Source: https://habr.com/ru/post/978468/


All Articles