1
  1. I'm currently implementing Google OpenID to achieve sign in with google on my website. Following the tutorial given by google. It emphasizes only the id_token is the thing to send to backend-sever. Since I'm using Java as backend and I couldn't find methods like getName() on id_token in google api library. I can only retrieve email by getEmail() though.

    So how can I get user's name at backend?

  2. Also, I realized the OpenID is the recommended in docs rather than Oauth2.0 if I only want to validate user's identity. I tried to implement Oauth2.0 too, but stuck on its working flow.

    Here is what I get so far.

    • button clicked ---> send a http get to certain api
    • that api got invoked and run scribeJava code
    • after I get the Authorization url, how do I open it as a popup window for user's confirmation?
    • and after confirmation, how to send the authentication code back to sever?

I know the blue map, but quite confused about the specific implementation.

Any help?

Qiang
  • 1,468
  • 15
  • 18

1 Answers1

-1
  1. It's better to use OAuth2 in my opinion: https://developers.google.com/identity/sign-in/web/reference#googleusergetbasicprofile Then you can fetch the basic user profile and then the username you wanted.

fetch_basic_profile Fetch users' basic profile information when they sign in. Adds 'profile' and 'email' to the requested scopes. True if unspecified.

  1. I believe you can use google api (gapi) for Oauth in Javascript. Here is the documentation: https://developers.google.com/api-client-library/javascript/features/authentication So here you can find a sample code to that: How to authenticate with Google via OAuth 2.0 in a popup?

Hope it helps :)

Community
  • 1
  • 1
m.aibin
  • 3,528
  • 4
  • 28
  • 47