-
-
Save kndt84/5be8e86a15468ed1c8fc3699429003ad to your computer and use it in GitHub Desktop.
Thank you!
When cachedSession.isValid() is false you get the Cognito User using user email. Can't we get the tokens again with refresh token only?
i was searching for this code for the past 2 days. Thank you for taking time to put this code up #
Question: in the official documentation (or better said: official examples) Use case 32, they use AWS.config.credentials.needsRefresh()
to test session validity, you are using cachedSession.isValid()
.
I've tried the first, I got a session that needs refresh every time I refresh a brower window.
Is there a way to just pass in the tokens from the web client down to the lambda function and make 'amazon-cognito-identity-js' use those tokens without needing the login name?
Can you explain, how it is being checked that session is valid or not. Because, right in yr code, i dont see any productive use of isValid().
Can you explain, how it is being checked that session is valid or not. Because, right in yr code, I don't see any productive use of isValid().
Yes, it has productive use. Access id and token come with an expiration time which can be configured from the console.
Here is the code behind isvalid(). It checks expiration time.
isValid() {
const now = Math.floor(new Date() / 1000);
return now < this.accessToken.getExpiration() && now < this.idToken.getExpiration();
}
Thank very much
what if accessToken is expired ?
You need to resend request with your refresh token
Thanks Thanks
Hello everyone! Thanks a lot for the answer.
For people who faced with Unable to verify secret hash for client
while refreshing the token, you can check the top answer for python
Short answer: simple use cognito:username
from a token as userName for refresh token request signing
Hello everyone!
How can I tell aws cognito make current access token is invalid after I call adminInitiateAuth
or initiateAuth
to refresh token?
Please help me.
I think you may need to revoke tokens before initiating auth via admin or initiateAuth.
getCognitoUser = function(req) { const poolData = { UserPoolId : COGNITO_USER_POOL_ID, ClientId : COGNITO_CLIENT_ID }; const userPool = new CognitoUserPool(poolData); const userData = { Username : req.user.email, Pool : userPool }; return new CognitoUser(userData); };
here I can write any email
, and result success )
I think this not correct
Does anyone here know how to update this to AWS v3 javascript sdk? i dont understand a thing about the new modular architecture
Thanks!