0

I am trying to implement the login process in my app using Cognito Hosted UI. I want if user is not logged in and try to access a page

www.example.com/a

To be redirected on the hosted UI page, and after login I want to redirect the user on his initial request www.example.com

How can I achieve this?

1 Answers1

0

maybe I misunderstood your question, but this is not something you should be able to do directly from cognito, the initial "catch-all" redirection should happen on your site's code.

Once you redirect it to your Cognito hosted UI, which should be a URL similar to this one:

https://{your cognito domain}/oauth2/authorize?client_id={your client id}&response_type=code&scope=aws.cognito.signin.user.admin+email+openid+profile&redirect_uri={your site's url}

Once the auth process is finished it will redirect the user back to you site.I need to point out that first you need to add your site's url in the list of allowed Callback URLs in your app client.

I wish I could be of more help, but how to handle auth on your app is very dependant on the technology you're using, if it helps you this thread discusses how to do this with nuxt and @nuxtjs/auth-next, this will probably give you some more insight into how to approach your problem

Lawrence Gil
  • 395
  • 4
  • 13