Google Drive API v3 的 Oauth2 范围请求不起作用

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

在我的应用程序中,我需要请求 Drive API v3 restricted Scope DRIVE。

我设法构建了请求 Email SignInOption,但是当它到达 Scope 请求时,它只是冻结在加载页面上。我尝试了多种类型的示波器,但它仍然不起作用。如果我取出 requestScopes 部分,它会完美地工作

这是我请求登录的代码

    // 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);
    }

这是我的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'

有人知道可能导致此错误的原因吗?

编辑: 我看到有一份关于这样一个问题的跟踪报告: https://issuetracker.google.com/issues/178183308

终于找到答案了!在 Google API 控制台中,只需简单地从测试状态中删除同意屏幕并发布它

来自: