amplify-js
amplify-js copied to clipboard
Hub does not currently emit an event when a refresh token expires or access token expires
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
# Put output below this line
OS: MacOS 13.5.2
CPU: (8) arm64 Apple M1 Pro
Memory: 51.52 MB / 16.00 GB
Node: 16.20.0
npm: 8.19.4
@aws-amplify/auth: ^6.0.10
@aws-amplify/auth: ^6.0.10
aws-amplify: ^6.0.10
Describe the bug
When access or refresh token is expired, no any event is sent to channel 'auth'. Page need to refresh manually to get new access token.
Expected behavior
When ever refresh token or access token expired, Hub should receive an event for 'auth' channel.
Reproduction steps
install the latest versions as mentioned above. Listen to events as following:
Hub.listen('auth', (msg:any) => { console.log('Event : ', msg) });
Used config:
Amplify.configure({
Auth:{
Cognito:{
userPoolId:'<id>',
userPoolClientId: '<id>',
loginWith: {
oauth: {
domain:'<domain>'
redirectSignIn: ['<url>'],
redirectSignOut: ['<url>'],
scopes: ['openid'],
responseType: 'token'
}
}
}
}
})
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Seems there is no counter or task running that checks the expiry time of token and then dispatch the event.
hello @mrSingh007 . Thank you for bringing this up. We currently have a fix for this issue which needs to be released.
Hello @mrSingh007 . The latest release included the fix, you should be able to get the hub event when the refresh_token
is expired
I have tested now in 5.3.15 and in version 6.0.12 of 'aws-amplify' and the issue is still there. No any event was dispatched, when token is expired.
@mrSingh007 you want an specific event when access or id token are expired? What is the use case?
Thanks!
@mrSingh007 you should be able to see signOut
event when the refresh_token
is expired. The library emits this event when there is an API call that tries to pull tokens (e.g. fetchAuthSession
API). The library cannot detect if the refresh_token
is expired without doing an operation with Cognito service.
@mrSingh007, did you get a chance to see @elorzafe's comment above? We'd like to know if there's additional context/use cases around this feature that we could work on. Would having just the expiration of the access token emit an event be enough here?
Hey, @mrSingh007 👋. It looks like you may have had a similar question/issue resolved in #12832. Since we haven't heard back from you on this issue, we'll close this out for now. Feel free to reply back if there's still a question or blocker here, thanks!