Search code examples
securityoauthoauth-2.0google-drive-api

Does OAuth 2.0 always require a browser in the flow?


Can I use OAuth 2.0 without a browser (or an embedded browser in my app) to perform nightly uploads?

Setup I have a refresh token and access token from provider console-- Google Drive API

I wish to use Java SDK to use/reuse these to upload data without the requirement for any browser authorization once i have initially received my refresh/access tokens.


Solution

  • Yes, that is what unattended access with the refresh token is about. When the user gives consent in the Google prompt they are allowing persistent access even when they are not logged in. You can store the refresh token on the server somewhere. When the access token expires then use the refresh token to request a new access token.

    Just to clarify some of the wording in your question, the refresh and access tokens do not form a pair. So saying "reuse these", should actually be "reuse this", where 'this' is the refresh token.