Google Drive Auth always returns 0

I use the code as shown in this https://developers.google.com/drive/android/auth#connecting_and_authorizing_the_google_drive_android_api

In my application, I click to connect to Drive, but this leads to the execution of this line

 connectionResult.startResolutionForResult(this, 1);

As the connection fails.

Then it opens the account menu so that I can select an account. When I click on it, the dialogue is rejected, and I still can’t connect to Google Drive, because every time the result code is 0

protected void onActivityResult(final int requestCode, final int resultCode,      final Intent data) {
    switch (requestCode) {
        case 1:
            if (resultCode == RESULT_OK) {
                mGoogleApiClient.connect();
           }
            break;
    }
}

I would suggest that the code is correct, but does anyone know what I need to do to prevent cancellation? I believe that I correctly configured my credentials for OA Auth

+4
1

Drive Google , . . :

@Override
    protected void onResume() {
        super.onResume();
        if (mGoogleApiClient == null) {
            mGoogleApiClient = new GoogleApiClient.Builder(this)
                    .addApi(Drive.API)
                    .addScope(Drive.SCOPE_FILE)
                    .addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .build();
        }
        mGoogleApiClient.connect();
    }

    /**
     * Handles resolution callbacks.
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_RESOLUTION && resultCode == RESULT_OK) {
            mGoogleApiClient.connect();
        }
    }

. , , Oauth CliendID, , .

:

enter image description here

0

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


All Articles