usingOAuth2德precated? [英] usingOAuth2 deprecated?

查看:554
本文介绍了usingOAuth2德precated?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用谷歌驱动器API的Andr​​oid应用程序。它最初是从快速入门例子构建这里。 API调用的简化序列(在这里没有显示正确的错误处理)为:

I've been working on an Android App that uses Google Drive API. It was originally build from the quickstart example here. The simplified sequence of API calls (with proper error handling not shown here) is:

 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();

据工作正常,我刚要释放我的应用程序。但突然间,驱动器API更新后​​,我得到一个警告

It has been working fine and I am just about to release my App. But suddenly, after Drive API update, I'm getting a warning

该方法usingOAuth2(背景下,字符串,字符串...)从类型   GoogleAccountCredential是pcated德$ P $

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

这是怎么回事?有另一种方式来获得证书?有快速入门例子的编辑版本可在任何地方?

What's happening? Is there another way to obtain credentials? Is there an edited version of quickstart example available anywhere?

先谢谢您的任何澄清。肖恩

Thanks in advance for any clarification. sean

推荐答案

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

So, the simple answer to my own question is

替换:

GoogleAccountCredential CRD =   GoogleAccountCredential.usingOAuth2(这一点,DriveScopes.DRIVE_FILE);

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

GoogleAccountCredential CRD =   GoogleAccountCredential.usingOAuth2(这一点,   Arrays.asList(DriveScopes.DRIVE_FILE));

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

这篇关于usingOAuth2德precated?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆