How to use Nhost Vanilla with Service workers or Extension Background script? #2493
-
Right now I am able to use the Javascript SDK, but the auth session details do not persist as the MV3 extension does not appear to be storing the session details correctly, I've tried a few different storage options but none have worked for me. I want to use a background script to query authenticated data from hasura, I am able to login, but not persist the login as authentication details are not available in the background script. Is there an alternative way to login where I can manually add the session token directly via an API call? Or even better, a way to use a chrome extension storage ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You have a few options when using the js SDK:
You have more details about those here: https://docs.nhost.io/reference/javascript/auth/types/nhost-auth-constructor-params Then you can leverage If the SDK doesn't provide the flexibility you need/want you can also perform HTTP requests directly to the services. You can find information about the endpoints here: https://docs.nhost.io/reference/auth/sign-up-email-and-password |
Beta Was this translation helpful? Give feedback.
-
I'm having an issue with async custom storage: I believe the async getter should be async? in
|
Beta Was this translation helpful? Give feedback.
-
In the end I gave up and am using the other contexts to interact with nhost - content scripts, popup etc. There is an issue with using storage in a background script in the extension where either the promise never returns or it returns empty - even though the data is stored. |
Beta Was this translation helpful? Give feedback.
You have a few options when using the js SDK:
autoSignin
andautoRefreshToken
clientStorage
You have more details about those here: https://docs.nhost.io/reference/javascript/auth/types/nhost-auth-constructor-params
Then you can leverage
setAccessToken
inside the graphql and storage options if you are planning to use those.If the SDK doesn't provide the flexibility you need/want you can also perform HTTP requests directly to the services. You can find information about the endpoints here: https://docs.nhost.io/reference/auth/sign-up-email-and-password