Authorize an application to use an existing folder

Using the Android Drive API when trying to connect using:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API).addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).build();

getGoogleApiClient.connect();

I get an account selection screen and after choosing an account I see the following:

enter image description here

View and manage your Google Drive files that you have opened or created with this application

What if I access files created by other applications?

Is there a way for my application to request authorization for a specific folder?

+4
source share
4 answers

The Google Play Services Client Library provides the Android API developer for seamless integration with individual Google services.

.

Google

Google Play Google Android API, Google .

Google Android API . drive.appfolder , , .

, API- REST, API Java. API Google API Java, Google, REST API (, Android)

Drive API v2 Java. libs - ( API Google API Java), (-, Android).

Android ( drive/readme.html)

google-api-services-drive-v2-rev143-1.19.0.jar
google-api-client-1.19.0.jar
google-api-client-android-1.19.0.jar
google-http-client-1.19.0.jar
google-http-client-android-1.19.0.jar
google-http-client-gson-1.19.0.jar
google-oauth-client-1.19.0.jar
gson-2.1.jar
jsr305-1.3.9.jar

Google ( Google) ( OAuth 2.0)

  • , Google Play Services, GoogleApiClient.

  • /Google API, , Google Play, REST API , , OAuth 2.0.

API Google Java ( v2). , -

, Google Play ( ), API Google Java Drive API v2 Java ( Google ).

-

.

+5

API Android Google :

drive.file: (https://www.googleapis.com/auth/drive.file) ,

drive.appdata(https://www.googleapis.com/auth/drive.appdata) " "

- Google (https://developers.google.com/drive/v2/reference/), API Google Java. (https://code.google.com/p/google-api-java-client)

: https://www.googleapis.com/auth/drive"

GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE); 
credential.setSelectedAccountName(accountName); 
Drive service = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build();
+4
+1
    mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(Drive.API)
        .addScope(Drive.SCOPE_FILE)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();

, addScope, , , , .

0

Source: https://habr.com/ru/post/1538962/


All Articles