0

we are using google picker to fetch the file in our application. Previously it was one time thing, but we noticed that because we don't allow data manipulation on our app, user need to do the changes on the drive and again do the upload/fetch process. We want to simplify the workflow and allow user to do one click refresh/resync of the file (spreadsheet). In order to do that I am thinking to save the file_id on my app, though I'll still need to get oAuthToken to build the service and fetch the file. Is that right approach or please suggest if any other mechanism I can follow.

The current google-picker workflow is using js on the client side which provides oAuthToken, fileId, Name of the file. on the server side I use python to build the service and fetch the actual file.

Mutant
  • 3,663
  • 4
  • 33
  • 53

1 Answers1

0

In my opinion, your process i.e, saving the file ID and access/refresh tokens and fetch the file when you need is the correct way to go.

I have built an application where we manage our files using google drive. In short my process was:

  1. User consent and Auth.
  2. Use picker to upload files and upon successful operation save necessary file data.
  3. Fetch the file (with access token or use refresh token to get new access token) whenever we need to view it to user

I hope this helps.

Cheers

arifin4web
  • 696
  • 8
  • 12
  • Thanks for the answer. So, do you save access token and file id both? I believe accesstoken get expire in few scenarios, so in that case you need to refresh the token. – Mutant Apr 28 '16 at 13:46
  • Yes, I saved fileID, AccessToken, And RefreshToken. As we fetch file, we need both the fileID and AccessToken. But access token is a short-lived one and we use RefreshToken to get a new one when one is expired. When user gives consent we get auth_code. This is a onetime code to get Access and Refresh token. Used that token to get access and refresh token and saved them in DB. Then when I need to fetch the file, I first check if the AccessToken is valid otherwise use RefreshToken to get a new access token and get the file. – arifin4web Apr 29 '16 at 00:41
  • I know it's been a long time but I was wondering if it is possible to use AccessToken previously obtained by consenting Google Drive access? (I have tried but doesn't work) If yes, How? Or is it another way to authenticate server-side?. My goal is to avoid asking the user to sign every time to search for files, and the user previously consented access to Google drive. – lucianov88 Jan 29 '21 at 04:52