Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 694
user1843591 Avatar asked Feb 25 '15 10:02

user1843591


People also ask

How does OAuth 2.0 authentication work?

It works by delegating user authentication to the service that hosts a user account and authorizing third-party applications to access that user account. OAuth 2 provides authorization flows for web and desktop applications, as well as mobile devices.

How does OAuth2 work in Web API?

For local login, Web API uses the resource owner password flow defined in OAuth2. The user enters a name and password into the client. The client sends these credentials to the authorization server. The authorization server authenticates the credentials and returns an access token.

Which OAuth 2.0 Flow should I use?

For most cases, we recommend using the Authorization Code Flow with PKCE because the Access Token is not exposed on the client side, and this flow can return Refresh Tokens. To learn more about how this flow works and how to implement it, see Authorization Code Flow with Proof Key for Code Exchange (PKCE).


1 Answers

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.

like image 61
Johannes B Avatar answered Sep 23 '22 03:09

Johannes B