I'm building a backend for an Android app using GAE (Java), and I'd like to authenticate users on the client and server with their Google accounts.
Before OAuth2, you were able to use a Cookie retrieved from the _ah/login endpoint to authenticate users into your web app, but that method is deprecated and I'd like to be able to use the updated OAuth2 method.
In my Android app I've been able to generate a JSON Web Token using the following line:
String jwt = GoogleAuthUtil.getToken(FamiliarActivity.this, Plus.AccountApi.getAccountName(mGoogleApiClient), "audience:server:client_id:1234567.apps.googleusercontent.com");
or an OAuth token:
String oauth2 = GoogleAuthUtil.getToken(FamiliarActivity.this, Plus.AccountApi.getAccountName(mGoogleApiClient), "oauth2:server:client_id:1234567.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login");
But, I haven't been able to figure out a way to use a token like this to trigger authentication in GAE like the Cookie used to. The documentation seems to indicate passing it as a header: "
Authorization: Bearer <TOKEN>" but that doesn't seem to work.
I'd like to be able to prompt my users with the permissions they're allowing, send that info (I'd assume via the OAuth2 token) to my server, and be able to obtain that user via the UserService.
What is the correct way to retrieve and pass a token to my GAE endpoint so that it authenticates the user?
Thanks! :)