Possible incompatibility of authentication API between aws-amplify and LocalStack

Hi All,

I am quite new to AWS-based development and LocalStack, and currently stuck in using the _aws/cognito-idp/oauth2/authorize API to perform user authentication and login.

The javascript library I am using is aws-amplify and I am able to configure it so as to obtain an authentication URL as follows:

https://localhost:4566/_aws/cognito-idp/oauth2/authorize?redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fdata-management&response_type=user_password_client%2Ccode&client_id=mrn2l3tuaizs6skarlfldu8uim&identity_provider=COGNITO&scope=&state=dbl67v3dOztFKn7p1XIxi2XWuIu4ritM

According to this LocalStack gitHub issue [1], it is supposed to be redirected to https://localhost:4566/_aws/cognito-idp/login?. However, it only works when the identity_provider field is removed from the above URL or it is set to empty.

I couldn’t find an approach to avoid embedding this field identity_provider in the URL parameters on the aws-amplify side. Thus, I would like to ask if LocalStack is able to handle this field when accessing oauth2/authorize API or it is due to a potential bug.

[1] bug: cognito's advertised authorize endpoint does not work · Issue #8062 · localstack/localstack · GitHub

Thanks and Best regards.

1 Like

Hello @jerome,

Thank you for the report. We have confirmed the issue and are currently working on an implementation that should resolve the problem. We will notify you once it is available in the latest LocalStack Docker image version.

1 Like

That’s great! Looking forward to the patch for this issue.

Hi @jerome,

Fix should be now available.
Please pull the latest version and give it a try

docker pull localstack/localstack-pro:latest

@Marcel Thanks for providing the patch, and now identity_provider seems not to be the road blocker for redirecting.

However, I am facing another issue, in which after authentication, I am redirected to the url http://localhost:5000/data-view?state=IDYUDjvYDKRfIUN2pCArfNCTvInTqD1X&code=332754, but shortly another page flashes (as shown in the attached image) and quickly I am again redirected to the above authentication page.

Would you happen to know the possible reason for this? Any hint is appreciated.

By using the dev tool of chrome, I saw one bad request targeting https://cognito-identity.eu-west-1.amazonaws.com/. Any idea on how it happens would help a lot.

It seems other fellow also encounters the same issue (Issues with Amplify JS and LocalStack: Authentication and S3 Endpoint Problems - #4 by crispinzon).