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.

Auth.currentSession keeps calling https://cognito-idp.<region>.amazonaws.com/

See original GitHub issue

Describe the bug Whenever Auth.currentSession() is called, it will do a request to https://cognito-idp.us-east-1.amazonaws.com/ (AWSCognitoIdentityProviderService.GetUser). I think session should be cached until it expires.

To Reproduce Steps to reproduce the behavior: Call:

let session = await Auth.currentSession(); 

Check network tab in (say) Chrome and see new request to https://cognito-idp.us-east-1.amazonaws.com/ Headers:

Content-Type: application/x-amz-json-1.1
DNT: 1
Origin: http://localhost:3000
Referer: http://localhost:3000/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
X-Amz-Target: AWSCognitoIdentityProviderService.GetUser
X-Amz-User-Agent: aws-amplify/0.1.x js

Expected behavior Auth.currentSession() returns cached version until it has expired. Token info does get stored in local storage.

Additional context aws-amplify:1.14 aws-amplify-react: 2.0.5

config:

Amplify.configure({
    Auth: {
        mandatorySignIn: true,
        identityPoolId: xxx,
        region: xxx,
        userPoolId: xxx,
        userPoolWebClientId: xxx,

    },
    Analytics: {
        disabled: true
    }
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
lgrapenthincommented, Nov 30, 2018

@powerful23 Please consider filing this as a bug. The implementation leaks HTTP requests, which is obviously not intended. IME it is not a feature to have unintended behavior removed.

5reactions
powerful23commented, Dec 4, 2018

@kjellski hey we just had an internal discussion around this issue. We will take an action to resolve this in the next two days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-amplify auth currentSession returns no current user
It looks like I cannot get user session, unless it is wrapped inside Auth.signIn. That's the Node/JS async programming model in a nutshell....
Read more >
Authentication - Password & user management - JavaScript
Auth. currentSession() returns a CognitoUserSession object which contains JWT accessToken , idToken , and refreshToken . This method will automatically refresh ...
Read more >
Retrieving user information from AWS Amplify authentication
This is a guide to three methods of retrieving user information from AWS Amplify authentication: Auth.currentSession(), Auth.
Read more >
Amazon Cognito Authentication - Cypress Documentation
In this loginByCognitoApi command, we call Auth.signIn , then use that response to set the items inside of localStorage for the UI to...
Read more >
Building an application with AWS Amplify, Amazon Cognito ...
The authorization header is what carries the id token. Caching is disabled in order to invoke the Lambda on every call and track...
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