Expired credentials are used after re-authentication
See original GitHub issueI have noticed this behaviour on the first request that is made after each time credentials expire.
In the code I see that there is a condition that checks if the credentials are expired. And if they are, this.authenticate()
(line 128) is called before the request is made.
But the function const req = () => {...
(line 85) uses stale credentials fetched from localStorage before re-authentication.
const credentials = JSON.parse(storage.get('moltinCredentials'))
const req = () => {
const headers = {
Authorization: `Bearer: ${credentials.access_token}`,
/* ... */
if (
!credentials ||
!credentials.access_token ||
credentials.client_id !== config.client_id ||
Math.floor(Date.now() / 1000) >= credentials.expires
) {
return this.authenticate()
.then(req) // <--- This uses the same credentials
.catch(error => reject(error))
This causes the request to fail with the message
{
"errors": [
{
"status": 401,
"title": "Unable to validate access token"
}
]
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Flow Connections error due to Credential Expiration
Solved: Hello All, We are having an issue with credentials expiring in Microsoft Flow Connections. The connections seem to expire every 2 weeks....
Read more >Reset your password for expired credentials - EA Help
Your login credentials have expired, but all you need to do is reset your password. Scan the QR code or use the URL...
Read more >CredentialExpiredException (Java Platform SE 7 )
This exception is thrown by LoginModules when they determine that a Credential has expired. For example, a LoginModule authenticating a user in its...
Read more >I am getting an "Invalid or expired credentials" error when ...
If you receive an error message saying "Invalid or expired credentials" or "Authentication Needed" when you try to sync, you will need to...
Read more >getting message "Authentication expired" on cisco router
If you are using local database for access, then it seems that those credentials have some how lost there privilege level or AAA...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @aravindanve I’m looking into this now and will get back to you once I confirm and patch.
I would send a PR right now, but your contribution rules look a little intimidating. 😅
I’ll try and do it later if I can take some time out.