question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide access to the underlying `auth0-spa-js` methods

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamjmcgrathcommented, Sep 3, 2021

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

0reactions
adamjmcgrathcommented, Sep 14, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Auth0 JavaScript SDK Quickstarts: Login
This tutorial demonstrates how to add user login to a Javascript application using ... Method to None and set the Application Type to...
Read more >
Announcing the General Availability of the Auth0 SPA JS SDK
Auth0 by Okta takes a modern approach to customer identity and enables organizations to provide secure access to any application, for any user....
Read more >
Auth0 Single Page App SDK
The Auth0 Single Page App SDK is a new JavaScript library for implementing authentication and authorization in single page apps (SPA) with Auth0....
Read more >
The Complete Guide to React User Authentication with Auth0
Calling this method prompts a user to authenticate and provide consent for your React application to access certain data on behalf of that...
Read more >
Authentication API Explorer - Auth0
An example is the Get User Info endpoint. In this scenario, you get an Access Token when you authenticate a user, and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found