Search code examples
androidauthenticationaccountmanager

How to authenticate user, using the Google account user_id to third party socket server


This tutorial was a grate help in understanding the AccountManager and authToken:
Nick's Blog Authenticating against App Engine from an Android app

I still need to get that to work with a basic Java SSL/TSL socket server where for now my Android users authenticates themselves with passwords.

UPDATE:
The Server works as relay station for the SPRIID app users.
With the SPRIID app you send files to other devices trough this dedicated java Server.
- Everything work trough C2DM(GCM)
- Backend MongoDb databas register users and frindlist's and handle transfer details
For test trying the app, install it, add yourself as friend, send something..

How can the server pars the authToken return with getAuthToken()?
Must my server run some GAE api?
Is the "Federated Login" the way to go and how?


Solution

  • Think i got it working now warning do Im still learning this

    In the Nick's sample code above im replacing the

    accountManager.getAuthToken(account, "ah", false, new GetAuthTokenCallback(), null);
    

    with

    accountManager.getAuthToken(account,"oauth2:https://www.googleapis.com/auth/userinfo.profile", false, new GetAuthTokenCallback(), null);
    

    Now i get a Token and can in my chrome browser do:

    https://www.googleapis.com/oauth2/v1/userinfo?access_token=ya29.AHeS6ZQpS0T0jipB0grWzuqINDdP98zjj-uljvw1GTR1_2s
    

    That will return this json

    {
     "id": "100864638927226952543326",
     "name": "Billy Bob",
     "given_name": "Billy",
     "family_name": "Bob",
     "link": "https://plus.google.com/13444649626952543326",
     "picture": "https://lh5.googleusercontent.com/--QPesNgxryI/AAAAAeewAAAI/AAAAAAAAAFo/J-LSwl0bcVU/photo.jpg",
     "gender": "male",
     "locale": "us"
    }
    

    What i wanted was the "id", that is suppose to be unique