How to use custom URI schemes in the redirect URI for native clients in Google OAuth Flows

3,153 views
Skip to first unread message

Naveen Agarwal

unread,
Feb 14, 2013, 12:43:12 PM2/14/13
to oauth...@googlegroups.com


How to use custom URI schemes in the redirect URI for native clients in Google OAuth Flows

Here is a technique to improve the flow when an iOS app wants to get an OAuth 2 token for a google account.  You send the user to the browser for approval, and the browser redirects back to a URI you supply.  The trick is to register and use a custom URI scheme for that redirect.

As an example, for the following bundle and client id:
     bundle id: com.example.myapp
     client id: 1234-abc.apps.googleusercontent.com
The client can use either of the following custom schemes:
     com.example.myapp:/oauth2Callback
     com.googleusercontent.apps.1234-abc:/oauth2callback

To use custom URI schemes:
 
Create a client id of type iOS (installed application) in the API console. Enter Bundle ID (Wildcards are supported e.g. com.mycompany.app1.*).
In your app register your custom URI scheme and handle the request. Extract the code and exchange it for a refresh token and store it.

More details: http://goo.gl/uax5i

G+ post: https://plus.google.com/111487187212167051233/posts/AztHNnQh7w6

Reply all
Reply to author
Forward
0 new messages