Reputation: 487
I am trying to replicate functionality of cognito hosted ui sign in page(https://docs.aws.amazon.com/cognito/latest/developerguide/login-endpoint.html), but aws sdk does not provide any method that would take username,password and would return authorization code which could be used for obtaining access/id token. The initiateAuth and adminInitiateAuth only support implicit flow which returns directly access/id token. Is there any workaround for this, how to retrieve authorization code?
With best regards, Jakub
Upvotes: 10
Views: 3719
Reputation: 717
There's no API that supports this functionality. It would be great if initiateAuth
and adminInitiateAuth
could respond with authorization code.
One of the workarounds suggested by AWS is for your backend to send a POST request with login and password to the login page in the hosted UI. I wouldn't recommend this solution though. It's unnecessarily complicated and doesn't work with MFA challenges. It may also impact brute force attack detection as well as the Advanced Security features because the original IP address of the user is masked by your backend IP address.
Upvotes: 12
Reputation: 534
You should use some SDK. Refer this link for examples of how to in a web environemtn https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-javascript-examples.html
Upvotes: -3