I am using AWS cognito to provide the JWT token auth for my apis.And i am using Authorization_code grand type.And when i click on View Hosted UI, it's redirecting me to login and after success giving the code and using that code, i am generating tokens.As f now it's fine.When i click the on View hosted UI again immedeatly, it's again generating new code, and previously generated tokens are not working.So How do i make the Hosted UI to not generate the code if already code is generated.Or How do i get the same code if already code is generated.Please help me on this.
Asked
Active
Viewed 79 times
1 Answers
1
Clicking on 'Hosted UI' will always try to log you in, as its noting but redirect to the /oauth2/authorize page with your parameters such as client_id,response_type,scope,redirect_url etc. For example, it will look like this.
https://<domain>.amazoncognito.com/oauth2/authorize?client_id=<client_id_here>&response_type=<your_response_type>&scope=<your_scope_here>&redirect_uri=<your_redirect_url_here>
I assume your question is for testing logic in your login process, and you don't want to open incognito session every time you want to test it. If this is the case, you can call the /logout endpoint after you have generated your tokens and finished processing it. This will invalidate the session, and ask you to login when you click 'Hosted UI' again.
The /logout endpoint should be called with GET request. Example
https://<domain>.amazoncognito.com/logout?client_id=<client_id_here>&redirect_uri=<your_redirect_url>&response_type=<your_response_type>&scope=<your_scope_here>
More about Logout endpoint in AWS Cognito here

VigneshwaraMoorthy
- 11
- 3