aws-amplify-react-native version 2.1.10 breaks withOAuth Custom Provider Authentication
See original GitHub issueDescribe 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
2 - Warning
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:19 (10 by maintainers)
Top GitHub Comments
I am facing the same issue can anyone help ??
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 🤢