Accessing Google Drive public folder from Android app without authentication
I want my application to be able to read from a predefined Google Drive shared public folder without having to log in or select a Google account.
Background / environment
Using my desktop browser, I created a shared folder in my Google Drive that is set to publish. Anyone with the link can access (read) the drive, so no authorization is required:
In my Android Studio project, I went to File > Project Structure > Dependencies
and addedcom.google.android.gms:play-services-drive:10.2.0
Now I have the opportunity to create new GoogleApiClient.Builder()
.
Question
I've looked at various examples, but in most cases the drive was generated by an Android app. This is not the situation I am trying to cope with.
This question is about disk access that was made public using a "folder id" or whatever you call 0B6X74x23H....
that was assigned when the folder was originally split and made public.
I looked at the demo code provided by Google , but this is presumably not for a shared folder because it says:
... the OAuth 2.0 client must be registered
At a minimum, I could manage the process with http-client, going to the link https://drive.google.com/drive/folders/0B6X74x23Hx7DNE13M0ZIbVI....?usp=sharing
without authentication and not needing to go through the hoops. But of course it would be easier to use a specific API and just specify a shared shared folder to display content and optionally download files from the shared folder.
When I try this code:
Scope publicFolder = new Scope(EXISTING_FOLDER_ID);
mGoogleApiClient = new GoogleApiClient.Builder(mActivity)
.addApi(Drive.API)
.addScope(publicFolder)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
This method works:
GoogleApiClient.OnConnectionFailedListener.onConnectionFailed()
The result contains statusCode=SIGN_IN_REQUIRED
. But, of course, no login is required for the public folder.
source to share
No one has answered this question yet
See similar questions:
or similar: