How to remove the “Have offline access” permission on Android using oAuth - android

I need to remove the “Have offline access” permission on my Android app.
In my application, when I click in sign me with Google it is showing me this:
I don't want that message
I'm using "GoogleApiClient" like this for the initialization:
// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.build();
I search over internet, but I can't found how to do that in Android. I only found information about Web Server Applications and the approval_prompt parameter.
Someone have any idea of how to do that on Android?
Thanks and sorry for my poor English

That is the scope of permissions your application is requesting. Users need to know what permissions you want to access If you want to remove that you will have to remove
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(Plus.SCOPE_PLUS_PROFILE)
But then you will not be able to access the users account either.

Related

Google Drive V3 Rest API Play Video Thru Drive App

I currently have 4 accounts connected to the Google Drive app on my phone.
I am trying to play a .mp4 file from Google Drive using the following:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(file.getFile().getWebContentLink())));
When I select the Google Drive app to play the file, I am presented with a list of the 4 currently connected accounts.
I already know which account the file is from. Is there any way of passing this account to the the startActivity, maybe as part of the intent?
Try below code it may work and let me know it worked for you or not.:)
#Override
protected void onResume() {
super.onResume();
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.setAccountName("yourmaild#gmail.com")
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
mGoogleApiClient.connect();
}

HistoryApi.readDailyTotal() does not work on Wear device

I'm developing watch face for Android Wear. I want to show on the face the steps recorded only by the wear device. According to Google Documentation this is possible with HistoryApi.readDailyTotal()
According to the documentation:
The system does not require authorization to access the TYPE_STEP_COUNT_DELTA data type from the HistoryApi.readDailyTotal() method. This can be useful if you require step data for use in areas where you are unable to show the permissions panel (for example, Android Wear watch faces and activities or widget activities). For more information on how to use this data in a watch face, see Showing Information in Watch Faces.
Unfortunately this does not work for me - GoogleApiClient always returns Connection failed: 5 - This means:The client attempted to connect to the service with an invalid account name specified.
This is my client:
mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
.addScope(Fitness.SCOPE_ACTIVITY_READ)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
Any idea how to tackle this problem? I'm facing hard time with this.
I've had similar issues getting the total on the wearable (local only), and this worked for me: do not add any scopes, and be sure to call useDefaultAccount. Hope this helps!
Ex:
mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
// Do not add any scopes if using the client on the watch
.addConnectionCallbacks(this)
.useDefaultAccount() // Use the default account
.addOnConnectionFailedListener(this)
.build();

Autocomplete Google Places sample

I'm trying to run the Google Place Code Sample, but I am not able to do it.
I am receiving error messages like:
Error getting autocomplete prediction API call: Status{statusCode=TIMEOUT, resolution=null}
I added my Google Map V2 ApiKey to the Manifest, and signed the app with the right certificate, so it seems that the key could be here:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addConnectionCallbacks(this)
.addApi(Places.GEO_DATA_API)
.build();
I am not sure what is supposed to be in the clientId slot, and there is not too much info out there. Just other people with the same problem but without solution.
By the way if somebody wants to take a look to the complete code it is here:
https://github.com/googlesamples/android-play-places/issues/3
This error can be caused by not enabling the Places API for Android in your Google Developer Console (This is different from the regular Places API).
It can also be caused if you set your API key using the old 'maps' identifier instead of com.google.android.geo.API_KEY, when adding the google meta-data to your application manifest.

Google Drive scopes deprecated?

I'm writing an app that would play media straight off Google Drive.
Google docs mention
https://www.googleapis.com/auth/drive.readonly
scope (see here: https://developers.google.com/drive/web/scopes) that seems exactly to be what I need. Yet, it seems that Android drive API supports only two of scopes mentioned there:
Drive.SCOPE_FILE
Drive.SCOPE_APPFOLDER
so I've tried several non-standard scopes like this:
mGoogleApiClient = new GoogleApiClient.Builder(XenoAmp.getContext())
.addApi(Drive.API)
//.addApi(DriveScopes.)
//.addScope(Drive.SCOPE_APPFOLDER)
.addScope(Drive.SCOPE_FILE)
.addScope(new Scope("https://www.googleapis.com/auth/drive"))
//.addScope(new Scope("https://www.googleapis.com/auth/drive.readonly"))
//.addScope(new Scope("https://www.googleapis.com/auth/drive.metadata.readonly"))
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
Yet my logcat complains:
03-29 12:53:58.935: E/ClientConnectionOperation(9953): com.google.android.gms.drive.auth.c: Authorization failed: Unsupported scope: https://www.googleapis.com/auth/drive
So - is drive scope no more supported? How can I get access to all user media files on Goodle Drive then?
Yes, the DRIVE scope is not supported in GDAA. If you need it, you have to go with the REST API. GDAA is not a 'newer' API, it is a different API. Both will be around for a while. You can compare these two here.

Google+ Login with Play Services 6.5.87 (GoogleApiClient) - Android

In Play Services 6.1.71 I was using:
mPlusClient = new PlusClient.Builder(this,this,this).setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN, Scopes.PROFILE).build();
But in Google Play Services 6.5.87, Google suggest to change PlusClient to GoogleApiClient.Builder instead. But I'm not able to get user info as before:
mPlusClient.getAccountName()
or
mPlusClient.getCurrentPerson()
How can I retrieve the user info? I think Google documentation is out of date.
Hope you can help me. Thank you.
Use GoogleApiClient, not PlusClient. Sample:
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
To getAccountName() use Plus.AccountApi.getAccountName(mGoogleApiClient)
To getCurrentPerson() use Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)
Very nice example how to implement login with GoogleApiClient ...
Since it is whole tutorial I do not copy it here.

Categories

Resources