usingOAuth2已弃用?

sea*_*npj 9 android oauth-2.0 google-drive-api

我一直在开发使用Google Drive API的Android应用.它最初是从这里quickstart示例构建的.简化的API调用序列(此处未显示正确的错误处理)是:

 GoogleAccountCredential cred = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE);
 cred.setSelectedAccountName("...");  
 Drive drvSvc = new Drive.Builder (AndroidHttp.newCompatibleTransport(), new GsonFactory(), cred).build();
 FileList gooLst = drvSvc.files().list().setMaxResults(MAX_DOWN).setQ(_rqst).execute();
Run Code Online (Sandbox Code Playgroud)

它一直工作正常,我即将发布我的应用程序.但突然之间,在Drive API更新后,我收到了警告

不推荐使用GoogleAccountCredential类型中使用OAuth2(Context,String,String ...)的方法

发生了什么?还有另一种获取凭证的方法吗?是否有可在任何地方使用的快速启动示例的编辑版本?

提前感谢您的任何澄清.肖恩

sea*_*npj 27

所以,对我自己的问题的简单回答是

更换:

GoogleAccountCredential crd = GoogleAccountCredential.usingOAuth2(this,DriveScopes.DRIVE_FILE);

GoogleAccountCredential crd = GoogleAccountCredential.usingOAuth2(this,Arrays.asList(DriveScopes.DRIVE_FILE));