Does OAuth 2.0 always require a browser in the flow

google-drive-apioauthoauth-2.0Security

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.

Best Answer

OAuth 2.0 requires a browser for user consent once

A browser is required, so that the user can agree to the request of the app to access the users data. After the user agreed on sharing the data with the app, the app can use the refresh token without a browser based flow.

Documented here: https://developers.google.com/accounts/docs/OAuth2WebServer

Alternative for non-browser apps

You may use the OAuth 2.0 for Devices flow: You app can act as a device which queries a code from google, displays it to the user, and asks the user to browse to a verification URL (e.g. with (system.out.println...).

So a browser is still needed, but your application itself doesn't need to provide a webpage to the user.