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.

AmplifyAuthenticator stuck in loading state after refresh

See original GitHub issue

Describe the bug After signing in with hosted UI, I am redirected to my React App and signed in. But the first time I refresh the page, I am stuck in loading state, no AuthStateChange gets fired. And yet, if I refresh again, I am signed in and it does not happen anymore for the session.

To Reproduce Steps to reproduce the behavior:

  1. Use AmplifyAuthenticator from @aws-amplify/ui-react
  2. Sign in from cognito hosted ui
  3. Refresh

Expected behavior I should stay signed in even after a simple refresh.

Additional context Here are the console logs in DEBUG:

[DEBUG] 01:26.759 Hub - Dispatching to auth with  {event: "parsingCallbackUrl", data: {…}, message: "The callback url is being parsed"}data: {url: "http://localhost:3000/app/"}event: "parsingCallbackUrl"message: "The callback url is being parsed"__proto__: Object
[DEBUG] 01:26.760 Hub - Dispatching to auth with  {event: "parsingCallbackUrl", data: {…}, message: "The callback url is being parsed"}
[DEBUG] 01:26.763 AnalyticsClass - on hub capsule auth {event: "parsingCallbackUrl", data: {…}, message: "The callback url is being parsed"}
[DEBUG] 01:26.764 Hub - Dispatching to auth with  {event: "parsingCallbackUrl", data: {…}, message: "The callback url is being parsed"}
[DEBUG] 01:26.764 Hub - Dispatching to auth with  {event: "configured", data: null, message: "The Auth category has been configured successfully"}
[DEBUG] 01:26.765 Hub - Dispatching to auth with  {event: "configured", data: null, message: "The Auth category has been configured successfully"}
[DEBUG] 01:26.765 AnalyticsClass - on hub capsule auth {event: "configured", data: null, message: "The Auth category has been configured successfully"}
[DEBUG] 01:26.766 Hub - Dispatching to auth with  {event: "configured", data: null, message: "The Auth category has been configured successfully"}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
jmannaucommented, Jan 14, 2021

I am also experiencing this with the following dependancies and Angular.

    "@aws-amplify/api": "^3.2.17",
    "@aws-amplify/api-graphql": "^1.2.17",
    "@aws-amplify/auth": "^3.4.17",
    "@aws-amplify/core": "^3.8.9",
    "@aws-amplify/pubsub": "^3.2.15",
    "@aws-amplify/ui": "^2.0.2",
    "@aws-amplify/ui-angular": "^0.4.17",

What seams to be happening is that the authenticator component checks if the page has been loaded from Cognito Hosted ui here - https://github.com/aws-amplify/amplify-js/blob/main/packages/amplify-ui-components/src/components/amplify-authenticator/amplify-authenticator.tsx#L88

   const byHostedUI = localStorage.getItem(REDIRECTED_FROM_HOSTED_UI);
    localStorage.removeItem(REDIRECTED_FROM_HOSTED_UI);
    if (byHostedUI !== 'true') await this.checkUser();

byHostedUi in this situation is 'true' and checkUser() is never called. Hence the component gets stuck in loading state

1reaction
wlee221commented, May 28, 2021

I opened #8357 to address this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AmplifyAuthenticator stuck in loading state after refresh
After signing in with hosted UI, I am redirected to my React App and signed in. But the first time I refresh the...
Read more >
AuthStatus is not changing from configuring state using ...
Flicker of login page on Authentication - useAuthenticator - React - Amplify Auth. Unfortunately now, the page is always stuck in the " ......
Read more >
Refreshing page cause "loading..." stuck forever
Hello, I am building a React app based on React quickstart found here on Auth0 docs . Login/Logout and token generation/retrieval from ...
Read more >
The Complete Guide to User Authentication with the Amplify ...
We can check for the status of a currently signed in user at any time using the Auth class from Amplify. Let's update...
Read more >
Complete Guide to Amplify and Next.js - Enlear Academy
The Amplify Framework provides the following services. ... If you are stuck at some point, you can refer to this original guideline on...
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