We’re trying to migrate our applications to Vue 3 and are refactoring our authentication logic. In our old code, we would access the access token through something like:
const token = await this.$auth.getAccessToken();
We’re now implementing a Pinia store that needs to get the access token from okta-vue. Through some inspection in Vue DevTools, I was able to see that I can get it via:
This doesn’t feel “right” to me. The underscore in the authState variable communicates that I’m referencing private state. Is there some other way to get the access token from the library?
Note that this code is not within a component, but it’s inside a Pinia store. I’m aware that within a component, I can access authState directly, but I can’t seem to find something similar within a store.
This at least removes the access to the private _authState variable. If anyone knows of another way we’re “supposed to” access the accessToken, I’m open to alternatives.