Code Monkey home page Code Monkey logo

Comments (27)

serm-mb avatar serm-mb commented on May 27, 2024 5

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024 3

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024 2

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024 1

You should be using tokenObj not xc. the xc 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?

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.

sirikhuncoins avatar sirikhuncoins commented on May 27, 2024

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.

Titozzz avatar Titozzz commented on May 27, 2024

Same Issue... Is there a way to permanently fix this ?

from react-google-login.

zachary95 avatar zachary95 commented on May 27, 2024

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

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.

zachary95 avatar zachary95 commented on May 27, 2024

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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

hmm if they changed the child keys that might be a bigger issue unless someone has the old ones somewhere?

from react-google-login.

zklinger2000 avatar zklinger2000 commented on May 27, 2024

+1 for the 3.0.0 change

from react-google-login.

zachary95 avatar zachary95 commented on May 27, 2024

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.

zachary95 avatar zachary95 commented on May 27, 2024

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.

zachary95 avatar zachary95 commented on May 27, 2024

Problem is, we don't have old child key yet.

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

Also does anyone know if the child keys change based on the scope?

from react-google-login.

zachary95 avatar zachary95 commented on May 27, 2024

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.

sirikhuncoins avatar sirikhuncoins commented on May 27, 2024

not sure if this one is related:
https://developers.google.com/identity/sign-in/web/reference

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

@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.

zachary95 avatar zachary95 commented on May 27, 2024

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.Paathus breaking my app. Still don't know why they are doing such things.

from react-google-login.

sirikhuncoins avatar sirikhuncoins commented on May 27, 2024

I've just tried this, and it works well for me :)

response.getAuthResponse().access_token
response.getBasicProfile().getEmail()

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

Pushed 2.4.0, Let me know if i am missing anything.

from react-google-login.

smarajitWOW avatar smarajitWOW commented on May 27, 2024

@anthonyjgrove Now the wc has changed to xc

Is this due to a change in Google's response?

Screen Shot 2020-11-18 at 5 17 03 pm

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

You should be using tokenObj not xc. the xc key seems to change now and then.

from react-google-login.

smarajitWOW avatar smarajitWOW commented on May 27, 2024

You should be using tokenObj not xc. the xc 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.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.