OAuth federation: Redirect User to the last requested page after authentication
See original GitHub issue** Which Category is your question related to? **
Amplify Auth Module
** What AWS Services are you utilizing? **
Cognito
** Provide additional details e.g. code snippets ** I’m currently using OAuth support for Amplify that was recently released. The challenge I’m running into with this new flow is redirecting a user to the last page they requested. I learned that Cognito app-client doesn’t allow for wildcard entries.
In this instance, I’m using Auth.federatedSignIn({ provider: 'Google' })
.When a user tries to access https://example.com?search=<random-guid>
in the unauthenticated state, the user gets presented with google prompt, after signing in, the user is redirected back to a redirectSignIn
url, which is a static location https://example.com
. I would instead want the user to be redirected back to the last page they requested, which is a https://example.com?search=<random-guid>
. I also learned that there is a way to pass a state
variable to Cognito, but struggling to find a way to do that in the using Amplify. Can you please provide a code snippet?
I’m using the authenticator component <Authenticator theme={authenticatorTheme} federated={federated} hide={[Greetings]} />
What I noticed is, this component with Auth.configure({ oauth })
adds “Sign In with AWS” button (Hosted UI) to the SignIn form. How do I hide that without hiding the whole SignIn component?
Can you please help?
Thanks, Rohit
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
@quyctd You can pass your page as a custom state
Auth.federatedSignIn({provider: 'Google', customState: JSON.stringify(route)})
and get it back in an auth event
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels or Discussions for those types of questions.