Closed NLLAPPS closed 5 years ago
The signed-in account will be saved by the Google Sign-In API until the user revokes it. If the user has already signed in to your app you can retrieve the GoogleSignInAccount as such: https://developers.google.com/identity/sign-in/android/sign-in#check_for_an_existing_signed-in_user
(If the user signs out of your app this will return null and you'll need to invoke a new sign-in workflow from the foreground. This is working as intended, as users always have the right to revoke account access to any non-Google process.)
Then you can rebuild the token from the GoogleSignInAccount. If you can't get this working feel free to open another issue.
Thank you for providing migration sample. However, it assumes app only connect when it is in the foreground.
Current Android SDK remembers authentication and provides client as long as token is valid. How would one manage this with REST client?
Imagine the following scenario:
User clicks on a button to authenticate with Google Drive to enable automated backup of data in the app. App starts
requestSignIn()
flow and user authorizes.Result is handled at
handleSignInResult
and new Drive Service created withDrive.Builder
and backup runs.So far so good. But, what would app needs to do to create a new instance of Drive service the next time automated backup runs? Is there any way to store the token and build instance of Drive service with it?