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

Automatically refresh the auth token in the example app #90

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

taylorreece
Copy link
Member

It's best practice to generate short-lived JWTs for the embedded markeplace, and to refresh the tokens before they expire. This adds a new config setting to the example embedded app, tokenValidSeconds, which determines how many seconds the token is valid for. The usePrismaticAuth hook is configured now to fetch a new token 30 seconds before the token expires. When a new token is detected, the useEffect within that hook re-issues a prismatic.authenticate() call with the new token.

@taylorreece taylorreece merged commit bd0008f into main Aug 16, 2024
1 check passed
@taylorreece taylorreece deleted the tr/auth-token-refresh branch August 16, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants