How to get the access token from Google Sign-In Javascript SDK?

后端 未结 2 665
渐次进展
渐次进展 2020-12-15 05:16

I have a simple single-page javascript webapp which uses \"Google Sign-In for Websites\": https://developers.google.com/identity/sign-in/web/sign-in

How can I get an

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 05:57

    For verification purposes it would be better to use the id_token which is part of the auth response, and can be retrieved at any point like this:

    gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().id_token
    

    The Google API Client libraries offer functions to verify the id_token and give you the associated user information on the server side: https://developers.google.com/api-client-library/

提交回复
热议问题