Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

android - Google Oauth2 scope request for Drive API v3 doesn't work

In my app I need to request the Drive API v3 restricted Scope DRIVE.

I managed to build the request Email SignInOption, but when it gets to the Scope request it just freezes on the loading page. I have tried with multiple types of scopes but it still doesnt work. If I take out the requestScopes part it works perfectly

This is my code to request the sign in

    // Request Google Sign In to user
            
public void requestSignIn () {

            Log.i("UploadFileActivity", "requestUserSignIn");

             
            GoogleSignInOptions signInOptions = new GoogleSignInOptions
                    .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestScopes(new Scope(DriveScopes.DRIVE))
                    .requestEmail().build()


            // it prints thi, but still doesnt request the scopes
            Log.i("UploadFileActivity", "requestUserSignIn");

            GoogleSignInClient client = GoogleSignIn.getClient(this, signInOptions);

            startActivityForResult(client.getSignInIntent(), 2);
    }

This is my gradle

// drive api dependencies
    implementation 'com.google.http-client:google-http-client-gson:1.26.0'
    implementation('com.google.api-client:google-api-client-android:1.26.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
         exclude group: 'org.apache.httpcomponents'
    }
    implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'pub.devrel:easypermissions:0.3.0'

    implementation 'com.google.android.gms:play-services-drive:17.0.0'
    implementation 'com.google.api-client:google-api-client:1.30.10'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'

Does someone knows what might be causing this error?

EDIT: I've seen there is a track report about an issue very like this: https://issuetracker.google.com/issues/178183308

question from:https://stackoverflow.com/questions/65923891/google-oauth2-scope-request-for-drive-api-v3-doesnt-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally found the answer! In the Google API console, just simply remove the consent screen from the test state and publish it

Got it from: https://stackoverflow.com/a/65900011/14990708


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...