Skip to content
This repository has been archived by the owner on Feb 21, 2018. It is now read-only.

Commit

Permalink
Fixing docs with docs link and title renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
Burcu Dogan committed Jul 24, 2013
1 parent 4e43225 commit 51bdf5a
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions README.md
Expand Up @@ -2,11 +2,11 @@

It's very common to build software with multiple components: a mobile app, Web back-end and etc. You Drive app should be in the same category and requires you to manage user authorization for multiple entities of the sample app. Google's OAuth 2.0 implementation provides some extentions to address the following cases:

* Help server-side to retrieve an acess token for itself, when user authorizes the Android app.
* Help Android app to identify user if user is once authorized with the server-side.
* Resolving user identity on Android apps without requiring the user to sign-in, if the user has already connected himself/herself on the Web application.
* Enabling an Android app to retrieve an exchange code for its server-side component.


**Warning**: These extentions are only available if authorization scopes contain `https://www.googleapis.com/auth/plus.login` to use Google+ sign-in.
**Warning**: These extentions are only available if authorization scopes contain `https://www.googleapis.com/auth/plus.login` for now.

## Configuration

Expand All @@ -22,20 +22,30 @@ final private List<String> SCOPES = Arrays.asList(new String[]{
});
~~~~

## Retrieve exchange code for server-side
## Resolve user identity with no sign-in

Retrieve an JSON Web Token (JWT) to identify user. You can exchange the JWT payload with your server-side to decrypt and identify user with his/her email address.

~~~java
String scope = "audience:server:client_id:" + CLIENT_ID;
String idToken = GoogleAuthUtil.getToken(context, accountName, scope);
~~~

## Retrieve access/refresh tokens for the server

~~~java
String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID, TextUtils.join(" ", SCOPES));
String exchangeCode = GoogleAuthUtil.getToken(context, accountName, scope);
~~~

## Retrieve a JWT to identify user on server-side
Send the code to the server and exchange your code with Google to retrieve an access and a refresh token for your server-side.

Retrieve an JSON Web Token (JWT) to identify user. You can exchange the JWT payload with your server-side to decrypt and identify user with his/her email address.
POST https://accounts.google.com/o/oauth2/token
Content-Type: application/x-www-form-urlencoded

~~~java
String scope = "audience:server:client_id:" + CLIENT_ID;
String idToken = GoogleAuthUtil.getToken(context, accountName, scope);
~~~
code=<exchangeCode>&
client_id=<CLIENT_ID>&
client_secret=<CLIENT_SECRET>&
grant_type=authorization_code

More details are explained on [Google's OAuth 2.0 public docs](https://developers.google.com/accounts/docs/CrossClientAuth).
More details are explained on [Google Drive's Cross-client Identity](https://developers.google.com/drive/auth/android#cross-client_identity) docs.

0 comments on commit 51bdf5a

Please sign in to comment.