android - usingOAuth2 已弃用?

标签 android oauth-2.0 google-drive-api

我一直在开发一个使用 Google Drive API 的 Android 应用程序。它最初是从 quickstart example here 构建的. 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();

它一直运行良好,我即将发布我的应用程序。但突然间,在 Drive API 更新后,我收到警告

The method usingOAuth2(Context, String, String...) from the type GoogleAccountCredential is deprecated

这是怎么回事?还有另一种获取凭证的方法吗?有没有quickstart example的编辑版本?随处可用?

提前感谢您的澄清。肖恩

最佳答案

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

替换:

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

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

关于android - usingOAuth2 已弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17429798/

相关文章:

java - 在 Java 配置中具有自定义身份验证管理器的 Oauth 授权服务器

perl - 你如何在 Perl 中编写 OAuth2 服务器?

node.js - 获取 Google Drive NodeJS 客户端的上传进度?

c# - .Net 中的 YouTube 和 OAuth 2.0

java - 使用 Google Drive API 从 Google Drive 直接下载

google-apps-script - File.getResourceKey 在 Google Apps 脚本中始终返回 null

java - 覆盖而不是附加数据的 FileOutputStream(FileDescriptor)?

java - 我可以在应用程序中发送两个 AlarmManager

java - 双向约束 View 有什么好处吗?

android - 为一次性设备构建应用程序