Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid that AWS Amplify OAuth tries to parse every oauth process

I'm working with a react-native application where i have implement the Authentication flow using AWS Amplify and Federated signin. This is the amplify configuration:

Auth: {
      identityPoolId: 'XXX',
      region: 'XXX',
      mandatorySignIn: false,
      userPoolId: 'XXX',
      userPoolWebClientId: 'XXX',
      oauth: {
        domain: env.AWS_OAUTH_DOMAIN,
        scope: ['email', 'profile', 'openid','aws.cognito.signin.user.admin', 'given_name', 'family_name', 'user_gender', 'user_birthday', 'user_location'],
        redirectSignIn: myapp://signin,
        redirectSignOut: myapp://logout,
        responseType: 'code',
      },
    },

Everything works fine. Until now.

Now i have to add another OAuth authentication for other purposes (connecting Strava to my application). Everything works fine, until the Strava authorization dialog redirect to my app at the url: runcard://profilo/servizi?code=XXX&scope=activity%3Aread%2Cread (this callback url is different from the one i've set for amplify configuration). Once redirected, amplify is there, ready to raise an exception by Amplify OAuth:

WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating '_a.accessToken')

I believe that since the callback url has a code parameter, Amplify is trying to do the job himself. Without success.

Does anyone faced the same issue?

like image 983
Angelica Rosa Avatar asked Oct 17 '25 20:10

Angelica Rosa


1 Answers

I found the cause of the issue!

Amplify is specifically looking for a param in any deeplinked URL called code.

I too was using code for a purpose other than the oauth callback (sign up confirmation code).

Changing the param to anything else (e.g. confirmationCode) prevents the accessToken error.

like image 127
James Avatar answered Oct 21 '25 09:10

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!