embedded
embedded copied to clipboard
Automatically refresh the auth token in the example app
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.