Question

I am really struggling to understand how this is done.

I have followed this example to be able to upload a file to our shared google drive account. This runs from the command-line on a linux box, but it requires me to copy/paste a URL into the browser, copy the authorization token, then paste it back into stdin, and exchange the auth token to finally get an access token.

All I need to do is to automate the process of having to copy/paste the URL and tokens around, so that my script just does what it needs to do, without any interaction from a user. The older DocumentsList API allowed us to authenticate simply with username/password. I know this is no longer possible with Drive's Oauth2 approach, but it would make my life a bit simpler right now..! Is there a way of using some kind of persistent token from my app?

Can anyone point me in the right direction?

Regards

Was it helpful?

Solution

You can gain an access token and refresh token pair and you can store them for use later. You only need the refresh token, since it can be used to get a new access token.

This is slightly better than username/password because you can revoke access to the token at any time if it has been leaked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top