Google Drive SDK - Drive Scopes

99封情书 提交于 2019-12-02 01:18:43

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

As you saw, currently only SCOPE_FILE is available on Android. Users much prefer that you have this scope, so that they can control which files your app accesses. You should be able to use the provided user interfaces to allow your users to browse all of the files and pick the one they want to use with your app. See OpenFileActivity.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!