question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws-amplify-react-native version 2.1.10 breaks withOAuth Custom Provider Authentication

See original GitHub issue

Describe the bug

After updating aws-amplify from version 1.1.24 to 1.1.25 and aws-amplify-react-native from 2.1.9 to 2.1.10, our React Native application’s authentication with a custom provider on a Cognito User Pool no longer works using the withOAuth HOC.

The error our app receives is (see screenshot 1):

NotAuthorizedException: Token is not from a supported provider of this identity pool.

At first glance, it looks like this PR introduced the bug: https://github.com/aws-amplify/amplify-js/pull/3005. I have a comment on that PR that provides some initial details as well.

The upgrade also introduces a YellowBox warning in our app (see screenshot 2):

Possible Unhandled Promise Rejection (id: 0)
TypeError: undefined is not an object (evaluating 'window.location.href')

To Reproduce Here is a code example similar to our code using the withOAuth HOC (generalized):

/*
 * @flow
 */

import React from 'react';
import {
  Button,
  StyleSheet,
  Text
  View,
} from 'react-native';
import { withOAuth } from 'aws-amplify-react-native';
import { Authenticated } from '../../views';

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

type Props = {
  oAuthError: ?string,
  oAuthUser: ?{},
  customProviderSignIn: Function,
  signOut: Function,
};

const SignIn = (props: Props) => {
  if (props.oAuthUser) {
    return (<Authenticated {...props} />);
  }

  return (
    <View style={styles.container}>
      <Text>Login</Text>
      <Text>{ props.oAuthError }</Text>
      <Button
        onPress={() => props.customProviderSignIn('azure')}
        title="Proceed to Login"
      />
    </View>
  );
};

export default withOAuth(SignIn);

Expected Behavior After clicking the “Proceed to Login” button the user is redirected using the device’s browser to the custom provider authentication page.

After the custom provider authenticates, the browser redirects to a deep link that opens our application and provides an OAuth2 code parameter and grant.

This process worked as expected with aws-amplify-react-native == 2.1.9 and aws-amplify == 1.1.24.

Current Behavior On aws-amplify-react-native == 2.1.10, the custom provider authentication works successfully in the browser and the deep link redirection occurs opening our application.

After our application opens, Amplify returns the following error:

NotAuthorizedException: Token is not from a supported provider of this identity pool.

Screenshots

1 - Error

Screen Shot 2019-04-09 at 4 20 19 PM

2 - Warning

Screen Shot 2019-04-09 at 4 05 07 PM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
rohitjain-devcommented, Jun 6, 2019

I am facing the same issue can anyone help ??

1reaction
mkrncommented, Apr 27, 2019

Before anyone spends too much time: this issue apparently is related to RN 0.59.0 and the way they implemented URLSearchParams https://github.com/facebook/react-native/issues/23922 🤢

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication - Social sign-in (OAuth) - React Native
Learn how to setup social sign-in providers like Facebook, Google, Amazon, or Sign in with Apple. - React Native - AWS Amplify Docs....
Read more >
aws-amplify-react-native | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Ampliy withAuthenticator v/s with withOAuth - Stack Overflow
I want to implement an authentication mechanism for react app. I am using AWS Amplify framework, It provides 3 methods either use custom...
Read more >
aws-amplify-react-native - npm
Latest version: 7.0.2, last published: 6 days ago. Start using aws-amplify-react-native in your project by running `npm i ... auth-hotfix.
Read more >
AWS Amplify + React Native / Authentication FULL SETUP
Cognito scales to millions of users and also supports logging in with social network providers such as Facebook, Google and Amazon. Cognito consists...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found