Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OAuth 2.0 for desktop and mobile applications

Tags:

oauth-2.0

I'm doing research on OAuth 2.0 protocol.

I came stuck in the problem of generating bearer tokens for desktop/mobile applications that don't run on a web server.

The OAuth 2.0 protocol flow is clear to me for web applications. Suppose myapp.com wants to access protectedresource.com on behalf of user Alice, then Alice gets redirected to https://protectedresource.com/oauth?redirect_uri=https://myapp.com/oauth&[...] so the resource manager, after obtaining consent, redirects Alice's browser to a page that will collect the authorization code and use it to obtain the bearer token.

This works fine and secure because protectedresource.com recognizes myapp.com domain and releases the bearer token only to requests coming from myapp.com

If I'm running a desktop application, even with support of a browser (ie embed an HTML viewer in a Windows Form or something like that) where am I supposed to redirect Alice after consent??

Who collects the authorization code? How does the control flow change?

Does anybody have examples of OAuth 2.0 implementations running on desktop or Android?

like image 446
usr-local-ΕΨΗΕΛΩΝ Avatar asked Dec 06 '12 22:12

usr-local-ΕΨΗΕΛΩΝ


People also ask

What is OAuth 2.0 used for?

OAuth 2.0, which stands for “Open Authorization”, is a standard designed to allow a website or application to access resources hosted by other web apps on behalf of a user. It replaced OAuth 1.0 in 2012 and is now the de facto industry standard for online authorization.

Is OAuth2 backwards compatible?

OAuth 2.0 is not backwards compatible with OAuth 1.0 or 1.1, and should be thought of as a completely new protocol. OAuth 1.0 was largely based on two existing proprietary protocols: Flickr's authorization API and Google's AuthSub.


1 Answers

The OAuth wiki lists numerous options you can use, all of which have downsides. The simplest involves you running a web app that can display the token to the user, and then the user copies the token (and maybe the refresh token) into your desktop app.

If you have plenty of time then you could investigate registering a custom URI with the desktop operating system, and then use that as the redirect_uri to automatically transfer back to your app from the browser. This has the best user experience.

A malicious app can easily pretend to be your desktop app in these scenarios, and security relies on your users not installing malicious apps.

like image 78
Patrick Avatar answered Oct 14 '22 07:10

Patrick