amplify-js: Auth.signIn throws NotAuthorizedException Incorrect username or password in ios

Do you want to request a feature or report a bug? Bug

What is the current behavior? In a react-native app I’m using Auth.signIn(username, password) to authenticate users.

The authentication success in android devices But in some ios devices the getting the following error. NotAuthorizedException. Incorrect username or password

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than AWS Amplify.

What is the expected behavior? In ios devices, should be able to authenticate with the same username and password as in android devices.

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions? “aws-amplify”: “^0.4.8” OS: ios

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 31 (13 by maintainers)

Commits related to this issue

Most upvoted comments

FWIW my issue was unrelated - I had a single missing char from a cut n paste error for my user pool id. It seems the messaging is a bit wrong in this scenario where the identity pool is correct but the pool was incorrect - the only thing that did not work was logging in.

VS Code gave me a big clue 😛

screen shot 2019-02-15 at 3 12 14 pm

Awesome news @mrowles !

post-mortem:

amazon-cognito-identity-js is doing an import like this:

import TypedArrays from 'crypto-js/lib-typedarrays';

where TypedArrays is unused; this is presumably making bundlers drop it when doing tree-shaking.

the import was changed to:

import 'crypto-js/lib-typedarrays';

Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only

Import a module for its side effects onlySection Import an entire module for side effects only, without importing anything. This runs the module’s global code, but doesn’t actually import any values.

@mrowles

I think I found the issue, while I send a PR, can you try adding this import before you import aws-amplify?

import 'crypto-js/lib-typedarrays'; 

@mrowles

Ok, I can reproduce with a simple

ng serve

vs

ng serve --prod

Let me keep looking into this, definitely a bundling issue

Did anyone figure this out? It’s happening to me now, same symptoms however it’s just web, not iOS or using Ionic. It works locally, but not in production, user is CONFIRMED etc.

@powerful23 Surely this is a widespread issue, it’s been 7 months since this was opened? I raised this as a ticket with business support too, but they don’t seem to have any clue.

@tonyatoms you should put that right after those import statements under index.js.

As a further observation it appears that the issue happens only on --prod ionic cordova builds

image If I only checked the last option it suddenly worked! (not sure if this helps anyone)

Nuts, looks good on local prod build! Pushing to my prod env to see if all swell, but positive outlook so far 😁Cheers

Edit: @manueliglesias can confirm this worked. Well done mate, this was a long outstanding issue that I (and others) struggled with for months.

@mrowles I’m wondering the same thing. Running “@aws-amplify/auth” v. 1.2.6 in create-react-app. Everything runs fine in Android, browser, and >= iOS 7. As far as I can tell, my issue is with Auth.signIn only. I’m having good luck with Auth.forgotPassword and Auth.forgotPasswordSubmit but the authentication flow fails there being that Auth.signIn must be called at the end of Auth.forgotPasswordSubmit - I’m assuming this since the new password is successfully submitted and changed, but still gets the error “NoAuthorizedException” that @manoramahp was initially getting (and what I’m getting when running Auth.signIn.