Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need better examples for using with authentication #933

Open
rmetcalf9 opened this issue Oct 23, 2023 · 1 comment
Open

Need better examples for using with authentication #933

rmetcalf9 opened this issue Oct 23, 2023 · 1 comment

Comments

@rmetcalf9
Copy link

Important gapi.auth2 notice: gapi.auth2 has been deprecated and replaced with Google Identity Services. Please see https://developers.google.com/identity/sign-in/web/deprecation-and-sunset for more information. If you have questions related to authentication/authorization please look at the associated documentation or post questions on Stack Overflow with the google-oauth tag.

(I don't know what the above means on the issue template. Should this library be used for calling google api's in a webapp)

Summary
I am working on a webapp which I want to use google login to call google API's while the user is present.
I have followed instructions here - https://developers.google.com/identity/authentication
I have generated a button and it is working and I can login and I get a response simular to the following in a javascript callback:

{clientId: 'xx', 
client_id: 'xx', 
credential: 'yyy', 
select_by: 'user'}

The credential is a valid JWT token and I have verified it at jwt.io.
The problem is I now need to know how to use this credential to call an API.
https://developers.google.com/identity/authorization says I should use a library to quickly and securly call google API's.
The links bring me to this repo.
I can see no reference to this credential anywhere in this repo.
This repo talks about an access token which is different to the credential JWT token. I can't find how I should be exchanging one to the other.

Can a sample be added to this library which shows how it should be used?

Browser(s)/Version(s)
All of them

Expected Behavior
I should come to this repo and it should have at least one example of how to use the credential to call an API.

Actual Behavior
I get lots of examples using an out dated method which won't work because new google client id's have this method disabled.

Steps to Reproduce
Try and develop a webapp that uses google API's.

@hermz365
Copy link

For authorization, you need access token. You can use Google Identity Services JavaScript for Web SDK to obtain access token. See https://developers.google.com/identity/oauth2/web/guides/overview.

There are more sample code under this page - https://developers.google.com/identity/oauth2/web/guides/migration-to-gis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants