Android Drive API: getting Sys.err UserRecoverableAuthIOException if i merge code to other projects

前端 未结 1 474
借酒劲吻你
借酒劲吻你 2020-12-19 09:12

I followed all steps listen under https://developers.google.com/drive/quickstart-android It works! But if im going to merge the given code/package to an other project, im ge

相关标签:
1条回答
  • 2020-12-19 09:44

    You should catch the UserRecoverableAuthException and in the catch block, you recover the Intent from the exception by calling UserRecoverableAuthException#getIntent(). Start that intent to take user to the OAuth2 permission page for your app.

    Sample code -

    try {
        Drive service = Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential)
            .build();
        // Do whatever you want with the Drive service
    } catch (UserRecoverableAuthIOException e) {
        startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
    }
    
    0 讨论(0)
提交回复
热议问题