3

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);
    });
  }

Punisher
  • 31
  • 1
  • 2
  • are you find the way ? – pery mimon Apr 15 '20 at 19:25
  • https://stackoverflow.com/questions/38268175/is-it-possible-to-use-oauth-2-0-without-a-redirect-server https://github.com/googleapis/google-api-php-client/issues/1473 https://stackoverflow.com/questions/54071294/how-to-login-directly-in-auth0-without-redirect-universal-login-page I found this and also I tried github approach but it did not work. – Punisher Apr 16 '20 at 06:41
  • ok. I think found the way. not with the `code` just with the credential we got from on-tap I checking it and when I finish I will publish it if it helps you – pery mimon Apr 17 '20 at 23:17

0 Answers0