Provide access to the underlying `auth0-spa-js` methods
See original GitHub issueDescribe the problem you’d like to have solved
When working with this library, one occasionally needs access to methods like getAccessTokenSilently
outside of a react component. For instance, inside a set of Apollo links (for refreshing the token when expired).
Describe the ideal solution
Ideally, this would include a way to get access to auth0-spa-js
outside of a hook, either by direct method access, or something like a ref pointing to the underlying library. This library abstracts a lot of the complexity, but having some kind of escape hatch would be great.
Alternatives and current work-arounds
Currently we handle this by passing the hook-provided getAcccessTokenSilently
method to a setter in our Apollo client setup file. If there’s a more elegant way to handle this, I’d be interested to hear alternatives, it feels a little kludgey. I think part of the issue is that there’s no great mechanism to update an existing Apollo link with a promise-resolved token. Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (3 by maintainers)
Hi @qbunt and all, I’ve created a guide as to why we don’t offer the option to pass your own SPA JS client into the Provider and what solutions we suggest to takle these sorts of problems here https://gist.github.com/adamjmcgrath/0ed6a04047aad16506ca24d85f1b2a5c
Closing as I think https://gist.github.com/adamjmcgrath/0ed6a04047aad16506ca24d85f1b2a5c answers the question