java.lang.IllegalStateException: Must not set scopes in GoogleApiClient.Builder when using Auth.GOOGLE_SIGN_IN_API

前端 未结 1 545
忘掉有多难
忘掉有多难 2021-01-23 15:41

I am using drive api with authentication api. I need to login to google account first then upload files to drive. Problem is when i use only drive api without authentication is

相关标签:
1条回答
  • 2021-01-23 16:22

    Try this code:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstance);
    
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }
    

    Then set the connection code for authorization to occur:

    @Override
    protected void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }
    

    I am following the documentation - Authorizing Android Apps, this documentation also provide give on how to handle ff the user has not previously authorized the application.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题