Open zoripong opened 4 years ago
Now the tc
field in res
somehow has been changed to wc
. According to https://github.com/anthonyjgrove/react-google-login/issues/17, this property name is unreliable.
I notice that there is a field tc
always contains access_token
when the access_token
is undefined
. I use it as an alternative.
Im getting accessToken: undefined in the main object and another object inside called wc which contains access_token.
also tried using getAuthResponse and it did not return an access token
Did anyone find a solution for that?
@Sultanyaron As the README and GoogleUser object said, You should add true
as
a parameter to getAuthResponse()
.
// You can always get the `access_token` in this way
res.getAuthResponse(true).access_token;
getAuthResponse
doesn't accept any arguments as per https://github.com/anthonyjgrove/react-google-login/blob/master/index.d.ts#L30
While calling res.getAuthResponse().access_token
returns undefined
for me
@Sultanyaron As the README and GoogleUser object said, You should add
true
as a parameter togetAuthResponse()
.// You can always get the `access_token` in this way res.getAuthResponse(true).access_token;
Can confirm that this properly sets the access_token
. @anthonyjgrove should we open a PR for this? At least set it to true
when access_type is token
@phanshiwen It is working properly and i am getting the token with the following:
//@ts-ignore
const googleAccessToken = loginResponse.getAuthResponse(true).access_token;
According to the definition file getAuthResponse don't accept args, this is something that need to get fixed.
Edit
Now the
tc
field inres
somehow has been changed towc
. According to #17, this property name is unreliable.I notice that there is a field
tc
always containsaccess_token
when theaccess_token
isundefined
. I use it as an alternative.
Now the wc
has changed to xc
Is this due to a change in Google's response?
hi.
Sometimes access_token is not defined after logging in.
So I debugged and found that function getAuthResponse, which is used in the library, was returning undefined.
The official document states that
access_token
is not returned when:I have to specify
fetched_basic_profile
as true, andscope
asprofile email
. The default value for this library is the same as the value I should use, so I didn’t specify it in the code.I am using the login component as below.
To solve this problem, I would like to modify the parameter of function
getAuthResponse
.Or is there another better solution?