Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hub does not currently emit an event when a refresh token expires or access token expires #12812

Closed
3 tasks done
mrSingh007 opened this issue Jan 8, 2024 · 8 comments
Closed
3 tasks done
Labels
Auth Related to Auth components/category feature-request Request a new feature Hub Related to Hub category

Comments

@mrSingh007
Copy link

Before opening, please confirm:

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

@mrSingh007 mrSingh007 added the pending-triage Issue is pending triage label Jan 8, 2024
@mrSingh007
Copy link
Author

Seems there is no counter or task running that checks the expiry time of token and then dispatch the event.

@israx
Copy link
Member

israx commented Jan 8, 2024

hello @mrSingh007 . Thank you for bringing this up. We currently have a fix for this issue which needs to be released.

@israx israx added Auth Related to Auth components/category bug Something isn't working and removed pending-triage Issue is pending triage labels Jan 8, 2024
@israx
Copy link
Member

israx commented Jan 12, 2024

Hello @mrSingh007 . The latest release included the fix, you should be able to get the hub event when the refresh_token is expired

@mrSingh007
Copy link
Author

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.

@nadetastic nadetastic self-assigned this Jan 23, 2024
@nadetastic nadetastic added the Hub Related to Hub category label Jan 23, 2024
@elorzafe
Copy link
Contributor

@mrSingh007 you want an specific event when access or id token are expired? What is the use case?

Thanks!

@cwomack cwomack added feature-request Request a new feature and removed bug Something isn't working labels Feb 12, 2024
@elorzafe
Copy link
Contributor

@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.

@cwomack
Copy link
Member

cwomack commented Apr 9, 2024

@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?

@cwomack
Copy link
Member

cwomack commented Jun 4, 2024

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!

@cwomack cwomack closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category feature-request Request a new feature Hub Related to Hub category
Projects
None yet
Development

No branches or pull requests

6 participants