Comments (27)
I use response.getAuthResponse().id_token
to get id_token
this work with both old and new object key
Should we use this function instead of response.hg.id_token which is used in readme?
I'm not sure if response.getBasicProfile()
will work too.
from react-google-login.
Also here is what I am looking at for updated key names:
property name | value | definition |
---|---|---|
googleId | string | Google user ID |
tokenObj | object | Token details object |
profileObj | object | Profile details object |
from react-google-login.
I guess it doesn't need to be a major release but it is a big change to those who have it implemented.
I think to properly patch this bug It would be good to map the child keys to their old values as well, then for the minor/ major version update rename the child keys to better names as well.
from react-google-login.
You should be using
tokenObj
not xc. thexc
key seems to change now and then.Thanks @anthonyjgrove for the response.
My use case required the
access_token
which isn't consistently available in the top-level and not available intokenObj
but has been available under thewc
or nowxc
keys. I have updated to now getaccess_token
viaresponse.getAuthResponse(true)
which seems to work great and thus removed dependency on these key names.But as part of root cause analysis, I wanted to understand what is the source of these inconsistent
wc
orxc
keys. Is it part of Google's response?
Can you make an PR with that logic? The component should probably be using that getter to set the accessToken inside the hook instead of grabbing it from the returned object. https://github.com/anthonyjgrove/react-google-login/blob/master/src/use-google-login.js#L37
from react-google-login.
Yes, I got the same issue. I believe the keys will change every time the library is compiled. Better have something to wrap this up.
from react-google-login.
Same Issue... Is there a way to permanently fix this ?
from react-google-login.
Just to be sure, this change is coming from Google ? Because what I've seen from this package is a function returning the response directly ..
If this is the case, we need to handle mapping (and give a sense to those ugly keys)
from react-google-login.
Yes, It looks like Google changed their response, it is probably best we figure out a good way to permanently map the Google keys to our own key names along with using better naming convention for those keys.
from react-google-login.
I am going to map it to the old keys for a quick fix so people don't need to update their code, then change the key names for the next version.
from react-google-login.
Pushed a quick fix, Let me know if you guys have any feedback on renaming the keys for version 3.0
from react-google-login.
Great @anthonyjgrove, thanks for the hotfix !
But I think it's even more than that, they also changed the child keys. I still ignore why they did such a thing, even more for completely sense-less keys.
from react-google-login.
hmm if they changed the child keys that might be a bigger issue unless someone has the old ones somewhere?
from react-google-login.
+1 for the 3.0.0 change
from react-google-login.
Sounds nice ! But is this deserve a major release ?
For old keys, I know profile picture was wc.Ph
now it's w3.Qaa
(???) and email was wc.hg
and now it's w3.U3
(???)
from react-google-login.
This might be kinda hardcore to map those data properly if even child keys are changing .. On what we gonna base mapping, positioning ?
If someone has news or blogpost to give about those changes, please provide them !
from react-google-login.
Problem is, we don't have old child key yet.
from react-google-login.
Also does anyone know if the child keys change based on the scope?
from react-google-login.
That's smart, I think one time I've saw functions to access data, maybe that's the way we should those login data, and passing through the object keys is doing hardcoding ...
from react-google-login.
not sure if this one is related:
https://developers.google.com/identity/sign-in/web/reference
from react-google-login.
@serm-mb Thanks for bringing that up. From what I can tell it is probably Google's intentions for developers to use the object's methods to access the returned information rather pulling it directly off the returned objects key., Then it would make sense for the keys to not have a straightforward naming structure and for them to randomly change them one day.
Moving foward should I update the docs to support only using the return object methods or should I also offer an updated naming structure as well if people just want to access it off the returned object like is currently outlined in the docs?
from react-google-login.
I think people will prefer having an object with all the data in it and meaningful keys (for those who wants to put directly the object in their store)
You can also include the response then @serm-mb 's people can still query with functions.
Of course, this deserve a minor release.
History has changed again : Now profile picture key is changing from w3.Qaa
to w3.Paa
thus breaking my app. Still don't know why they are doing such things.
from react-google-login.
I've just tried this, and it works well for me :)
response.getAuthResponse().access_token
response.getBasicProfile().getEmail()
from react-google-login.
Pushed 2.4.0, Let me know if i am missing anything.
from react-google-login.
@anthonyjgrove Now the wc
has changed to xc
Is this due to a change in Google's response?
from react-google-login.
You should be using tokenObj
not xc. the xc
key seems to change now and then.
from react-google-login.
You should be using
tokenObj
not xc. thexc
key seems to change now and then.
Thanks @anthonyjgrove for the response.
My use case required the access_token
which isn't consistently available in the top-level and not available in tokenObj
but has been available under the wc
or now xc
keys. I have updated to now get access_token
via response.getAuthResponse(true)
which seems to work great and thus removed dependency on these key names.
But as part of root cause analysis, I wanted to understand what is the source of these inconsistent wc
or xc
keys. Is it part of Google's response?
from react-google-login.
wc and xc are returned by google but I do not think they expect you to access them directly but use the getters like you are doing now.
from react-google-login.
Related Issues (20)
- SignIn is deprecated for new client application HOT 9
- This document requires 'TrustedScript' assignment. HOT 1
- React 18 HOT 14
- Is the "sub" identifier permanent for particular google account? HOT 2
- The login button is disabled everytime while implementing on next.js. But works fine in terms of react.js. Does this package have support for next? HOT 1
- could not peer react@"^16 || ^17" from [email protected] HOT 12
- popup_closed_by_user HOT 13
- Missing required parameter HOT 4
- Google deprecation-warning HOT 3
- include_granted_scopes default set to true
- Not compatible with React 18 HOT 1
- Not able to filter emails HOT 3
- Still maintained? HOT 2
- 403: Request had insufficient authentication scopes.
- Error "popup_closed_by_user" HOT 3
- OnFailure Method is silently called when page loads and when successfully logged in to Google. HOT 1
- user authentication or authorization deprecation issue HOT 2
- login button is disabled in Production HOT 5
- Migrate to Google Identity Services from Google Sign-In JavaScript library HOT 1
- Please Archive this repo !
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-google-login.