question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
andriworldcommented, Apr 6, 2021

@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

Hub.listen('auth', ({payload: {event, data}}) => {

  switch (event) {
    case 'signIn':
      user = data
      break

  case 'customOAuthState':
      route = JSON.parse(data)
      // go to route
      break;
  }
})
0reactions
github-actions[bot]commented, Apr 7, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirect Users - Auth0
Redirect Users. You can return users to specific pages (URLs) within your application after validating their ID Tokens (authentication).
Read more >
OAuth 2: redirecting a user to the original URL after login
When the login procedure is successful, the user is redirected back to your site, using the redirect_uri that was configured, for example https://somesite.com/ ......
Read more >
Authorize endpoint - Amazon Cognito - AWS Documentation
Use the authorize OAuth 2.0 and OIDC endpoint to sign in to Amazon Cognito. ... The URL where the authentication server redirects the...
Read more >
Redirect to the Previous URL After Login with Spring Security
And appending original URL to the redirected login URL is usually seen in SSO implementations. When authenticated via an SSO service, users will ......
Read more >
Manual Chapter: OAuth Client and Resource Server - AskF5
Specifies an auth-redirect-request type request, which redirects a user to an OAuth server. Displays when Grant Type is set to Authorization code. Token...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found