react-oauth
react-oauth copied to clipboard
Get credentials with custom button
Hello, thanks for this package. Is it possible to get credientialResponse with custom buttons ? (and not tokenResponse) thanks for your help
Hey @christophe13012, did you figure it out?
Hi!, you can but with authorization code flow, after exchanging the code with your backend you will get access, refresh, and id tokens
or if you are using it in implicit flow to get access token you can send request to google API to get user info
Hi @MomenSherif Is there any direct way to get user credentials with custom button? Can you provide some examples for it?
Would love to see this
You can get the user's credentials with this code.
const login = useGoogleLogin({
onSuccess: async (res) => {
const { data } = await axios(
"https://www.googleapis.com/oauth2/v3/userinfo",
{
headers: {
Authorization: `Bearer ${res?.access_token}`,
},
}
);
console.log(data);
},
});
@theviralboy I am sorry for my silly question, where can I put your code to run :( I want to use Calendar API but I can not get refresh token, I can use default google button to login and I stuck, could you help me out of this , thank you so much
@theviralboy I am sorry for my silly question, where can I put your code to run :( I want to use Calendar API but I can not get refresh token, I can use default google button to login and I stuck, could you help me out of this , thank you so much
I think it's a separate issue. I am also not getting the refresh token.
@theviralboy I am sorry for my silly question, where can I put your code to run :( I want to use Calendar API but I can not get refresh token, I can use default google button to login and I stuck, could you help me out of this , thank you so much
Try this https://www.npmjs.com/package/googleapis#oauth2-client