I know that I can use the access token that I receive in the response can be use to authenticate users. But I want it to be more secure So I want the code that we get in oAuth 2.0. Is there any way to get the code in the background to authenticate the user in one tap sign In?
An authorization code response that we get from the server is like this in url:
https://oauth2.example.com/auth?code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7
componentDidMount() {
this.registerNewUser();
}
retrievePromise() {
window.googleyolo.retrieve({
supportedAuthMethods: [
'https://accounts.google.com',
],
supportedIdTokenProviders: [
{
uri: 'https://accounts.google.com',
// Replace with your client Id
clientId: 'XXX...XXX.apps.googleusercontent.com',
},
],
});
}
// eslint-disable-next-line class-methods-use-this
registerNewUser() {
window.googleyolo.hint({
supportedAuthMethods: [
'https://accounts.google.com',
],
supportedIdTokenProviders: [{
uri: 'https://accounts.google.com',
// Replace with your client Id
clientId: 'XXX...XXX.apps.googleusercontent.com',
}],
context: 'signUp',
}).then((credential) => {
console.log(credential);
this.props.doGoogleLogin('login');
this.props.decideWhichSocialLogin(this.props.location);
/* hit backend api and API TOKEN here */
/* Also save basic details that we get here */
}, (error) => {
console.log('Error occurred: ', error.type);
});
}