Google Drive SDK - 驱动器范围 [英] Google Drive SDK - Drive Scopes
问题描述
我试图使用这个:
https://developers.google.com/drive/android/get-started
这是Android版Google驱动器SDK。
我希望能够列出用户Google云端硬盘帐户中的所有文件。但只能访问应用程序创建的文件和文件夹(或用户选择的文件夹)。
mGoogleApiClient =新的GoogleApiClient。 Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build ();
Google开发者可以告诉我是否可以使用此SDK列出用户文件和文件夹,以及检索元数据?只有SCOPE_FILE访问权限是被允许的。
如果没有,将来会有更多访问权限吗?
尝试过(并且悲惨地失败)以使用Java库,但我无法使其工作。所以希望我能找到新的SDK将包括其他权限(这是Java库)。
谢谢
我的解决方案是使用 google-http- java-client 库和 google-api-client 库,而不是谷歌驱动SDK for Android。主要好处是您可以访问Google驱动器上的所有文件。以下是代码中创建Drive对象的部分代码,然后您可以使用此对象访问文件。
final GoogleCredential凭证=新的GoogleCredential.Builder()
.setTransport(httpTransport).setJsonFactory(jsonFactory)
.addRefreshListener(refreshListener)
.setClientSecrets(clientId,clientSecret).build()
.setRefreshToken(refreshToken).setAccessToken(的accessToken);
//创建一个新的授权API客户端
final Drive drive = new Drive.Builder(httpTransport,jsonFactory,
credential).build();
I am trying to use this:
https://developers.google.com/drive/android/get-started
Which is the Google drive SDK for Android.
I want to be able to list all files in a users Google drive account. But only access is given to files and folders that the app created (or that the user selects).
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
Can Google Devs tell me if it is possible to List a users files and folders with this SDK, and retrieve metadata? Only SCOPE_FILE access is permitted.
If not, will more access be given in the future?
I have tried (and failed miserably) to use the Java Library but I cannot get it to work. So hopefully I can find out of the new SDK will include other permissions (which the Java library does).
Thanks
My solution is use google-http-java-client library and google-api-client library instead of google drive SDK for Android. The main benefit is that you can access all the files on the Google drive. below is a section code to create the Drive object in code, then you can use this object to access the files.
final GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport).setJsonFactory(jsonFactory)
.addRefreshListener(refreshListener)
.setClientSecrets(clientId, clientSecret).build()
.setRefreshToken(refreshToken).setAccessToken(accessToken);
// Create a new authorized API client
final Drive drive = new Drive.Builder(httpTransport, jsonFactory,
credential).build();
这篇关于Google Drive SDK - 驱动器范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!