Closed paulsjohnson91 closed 2 years ago
Hi @paulsjohnson91 👋 Did you use Expo or the React Native CLI to create your project? Also, can you post the contents of your package.json
file?
Hi @chrisbonifacio, My application was created using the react native cli, full package:
"dependencies": {
"@aws-amplify/analytics": "^5.0.15",
"@aws-amplify/api": "^4.0.15",
"@aws-amplify/auth": "^4.3.5",
"@invertase/react-native-apple-authentication": "^1.1.2",
"@react-native-async-storage/async-storage": "^1.15.5",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/google-signin": "^4.0.3",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "^5.9.1",
"@react-native-community/push-notification-ios": "^1.8.0",
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
"@react-native-firebase/analytics": "^10.8.1",
"@react-native-firebase/app": "10.8.1",
"@react-native-firebase/messaging": "10.8.1",
"@react-navigation/bottom-tabs": "5.11.11",
"@react-navigation/native": "5.9.4",
"@react-navigation/stack": "5.14.5",
"amazon-cognito-identity-js": "^5.0.5",
"aws-amplify": "^4.2.9",
"aws-amplify-react-native": "^5.0.3",
"crypto-js": "3.3.0",
"fuse.js": "^6.4.0",
"fuzzy": "^0.1.3",
"fuzzy-search": "^3.2.1",
"moment": "^2.24.0",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-app-intro-slider": "^4.0.4",
"react-native-background-timer": "2.2.0",
"react-native-calendars": "^1.1129.0",
"react-native-camera": "^3.26.0",
"react-native-collapsible": "^1.5.2",
"react-native-config": "^1.2.0",
"react-native-deep-linking": "^2.2.0",
"react-native-dialog": "^5.6.0",
"react-native-elements": "^2.0.0",
"react-native-fast-image": "^8.1.5",
"react-native-fbsdk": "^2.0.0",
"react-native-floating-action": "https://github.com/ramonvermeulen/react-native-floating-action.git#fixForNativeDriverWarning",
"react-native-floating-label": "^0.2.3",
"react-native-gesture-handler": "^1.6.1",
"react-native-inappbrowser-reborn": "^3.6.3",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-keychain": "^6.0.0",
"react-native-markdown-display": "^7.0.0-alpha.2",
"react-native-modal-datetime-picker": "^10.2.0",
"react-native-modest-checkbox": "^3.3.0",
"react-native-popup-menu": "^0.15.7",
"react-native-push-notification": "^7.4.0",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^2.8.0",
"react-native-share": "^3.3.2",
"react-native-side-drawer": "^1.2.6",
"react-native-simple-toast": "^1.1.2",
"react-native-size-matters": "^0.4.0",
"react-native-snap-carousel": "3.9.1",
"react-native-spinkit": "^1.5.0",
"react-native-splash-screen": "^3.2.0",
"react-native-svg": "^12.1.0",
"react-native-svg-transformer": "^0.14.3",
"react-native-tab-view": "^2.14.2",
"react-native-vector-icons": "^6.6.0",
"react-native-view-shot": "^3.1.2",
"react-native-walkthrough-tooltip": "^1.1.9",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"tcomb-form-native": "^0.6.20",
"url-parse": "^1.4.7"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"jest": "^26.0.1",
"metro-react-native-babel-preset": "^0.59.0",
"react-native-linear-gradient": "^2.5.6",
"react-test-renderer": "16.13.1"
},
@paulsjohnson91 thank you! unfortunately, I haven't been able to reproduce this error. I'm getting different error messages with the same package versions.
UsernameExistsException
InvalidParameterException
Successful Sign Up
This might be worth trying: https://stackoverflow.com/questions/58904776/aws-cognito-amplify-auth-signin-no-matter-what-returns-notauthorizedexception
If that doesn't work, also try to upgrade your Amplify related packages as that seems to have helped in the past: https://github.com/aws-amplify/amplify-js/issues/485
If neither work:
Can you share how you're importing and configuring Amplify (where you're calling Amplify.configure
) as well as the Auth library?
Hi @chrisbonifacio, thanks I've looked into those two, I already have the top one in place my config is.
I've also ensured that all my packages are up to date but I'm still getting
{ code: "NotAuthorizedException", name: "NotAuthorizedException", message: "Incorrect username or password." }
For all use cases
Auth.configure({
userPoolId: '<id>',
userPoolWebClientId: '<id>',
identityPoolId: '<id>',
logins: {
google:
'<id>.apps.googleusercontent.com',
},
region: 'eu-west-1',
federatedTarget: 'COGNITO_USER_POOLS',
authenticationFlowType: 'USER_PASSWORD_AUTH',
oauth: {
options: {
urlOpener: async (url, redirectSignIn) => {
await InAppBrowser.isAvailable();
console.log(url);
const response = await InAppBrowser.openAuth(
url,
redirectSignIn ? redirectSignIn : '<url>',
{
dismissButtonStyle: 'cancel',
showTitle: false,
enableUrlBarHiding: true,
enableDefaultShare: false,
},
);
if (response.type === 'cancel') {
console.log(response);
navigate('Auth', {
screen: 'HOME',
});
} else if (response.type === 'success' && response.url) {
Auth.currentAuthenticatedUser()
.then(() => {
navigate('USER', {
screen: 'SETPREFERENCES',
});
})
.catch((err) => {});
Linking.openURL(response.url);
}
},
},
domain: '<domain>',
scope: [
'phone',
'email',
'profile',
'openid',
'aws.cognito.signin.user.admin',
],
redirectSignIn: '<url>',
redirectSignOut: '<url>',
responseType: 'code',
},
});
what version of @aws-amplify/cli
are you using?
I don't have @aws-amplify/cli installed
@paulsjohnson91 oh okay, so you created the auth resource (Cognito User/Identity Pool) in the console?
That's correct yes. All the error messages were working a month ago as I was expecting them.
@paulsjohnson91 I think this might have to do with your authenticationFlowType
in the configuration. According to the Cognito documentation:
User name password based authentication
In the authentication flows for ADMIN_USER_PASSWORD_AUTH and USER_PASSWORD_AUTH the user name and password returns with a single call of InitiateAuth. Amazon Cognito returns a generic NotAuthorizedException error indicating either the user name or password is incorrect.
just out of curiosity, could you try changing the authenticationFlowType
field to "USER_SRP_AUTH" instead? Also, plesae confirm that your User Pool matches these settings in the Cognito console -> User Pools -> select your pool -> App clients.
Hi Chris, I've just attempted a sign in with a non existant user with both USER_PASSWORD_AUTH and USER_SRP_AUTH and the results were the same, NotAuthorizedException
ICan confirm that all those auth flows are selected for my cognito
I've also tried the same scenario with a user that hasn't been verified yet, this is an issue because if the user restarts the app and isn't verified there is no way for me to know if I need to provide the option to resend the verification email
Hi @paulsjohnson91 sorry for the delay. I can't see anything wrong with your auth configuration. Can you share the code where you're calling Auth.signIn
and also export a har file for the network requests? Once you do, please send the har file in an email to me at christopher.bonifacio@gmail.com. Thank you.
Also, if you think it might help, please feel free to schedule some time for a call with me.
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
No matter the scenario, i.e. user doesn't exist, user not verified, password incorrect, password reset required, etc, the amplify module is now only responding with the error code 'NotAuthorizedException'. This causes numerous problems because for one I don't know what to do next, for two you cannot tell the user what is wrong. Up until last month, the error code gave you more details on what the error was as shown in expected behavior.
This seems to be the case for Auth.signUp and Auth.signIn
Expected behavior
Previously my app has used the following:
For example, if the user had signed up but not confirmed their email, amplify would return the error code 'UserNotConfirmedException' so I could tell the user to go and verify their email or request a new one.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response