How to update auth token using app-extension-apollo each time a user log in?
Hello, I have a working demo using quasar, axios, and a rest api backend (jwt auth).
Following @Hawkeye64 guidelines (https://forum.quasar-framework.org/topic/5100/how-can-i-pass-the-jwt-token-to-axios-get-request/7) it works well, axios instance are saved on vuex store, and when users log in an action calls a mutation. This mutation update axios instance header (token jwt). It checks when the token expires on router.beforeEach and axios request (401). When the token expires I redirect the user to the login screen (in the future I wish I could check the validation date of the token and renew the token before the expiration date).
I have an api platform backend with graphQL and I would like to test it. I would like to update apolloClient object each time the user login similar as I am doing with the axios object:
axiosInstance.defaults.headers.common.Authorization = 'Bearer <token>'
But I don’t find how I could update the apolloClient object when users log in and update the token. Everybody creates a new apolloClient object:
Maybe, I am missing an obvious method or simple change on apolloClient object for example on apolloClientAfterCreate function?
Thank you very much
I was obsessed with apolloClientAfterCreate. It was more simple using apolloClientBeforeCreate.
I configure a function getToken() on apolloClientBeforeCreate.
Can you share the full implementation here. Plz