It is possible to authenticate a Google user ( the one logged in on an android device ) to my server using the auth_token obtained form Google?

前端 未结 1 644
南笙
南笙 2021-01-03 06:49

I have an Android app which let the users to add content to my server. Each user should have an account on this server.

The app communicate with the server through

1条回答
  •  走了就别回头了
    2021-01-03 07:28

    There should be a way of sending the auth_token to google and retrieving information like the google user_ID since you can retrieve those infos :

    {
      "audience":"8819981768.apps.googleusercontent.com",
      "user_id":"123456789",
      "scope":"https://gdata.youtube.com",
      "expires_in":436
    }
    

    by making a POST from your android app on : https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=1/fFBGRNJru1FQd44AzqT3Zg with the access token ... It's even indicated in https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2#OAuth2_Authentication The problem is that when you want to do it from your php server you'll have to send it in SSL because google requires it ... Here is my code :

    
    

    it just needs to be adapted to SSL and it should work to retrieve the google user_id ! After what you can compare it with the one in your database and the logg is done !

    By the way, could you share your code with us (using your method with auth_token for contacts) ? or send it to fakeclark@live.com THANKS ;-)

    0 讨论(0)
提交回复
热议问题