Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use with JWT token Bearer Authorization #18

Closed
vesper8 opened this issue Jan 13, 2019 · 1 comment
Closed

how to use with JWT token Bearer Authorization #18

vesper8 opened this issue Jan 13, 2019 · 1 comment

Comments

@vesper8
Copy link

vesper8 commented Jan 13, 2019

When I initialize VuexORMAxios I do not yet have my authorization token since the user isn't logged in yet at that point.

VuexORM.use(VuexORMAxios, {
  database,
  http: {
    baseURL: (process.env.NODE_ENV === 'development' && !process.env.CORDOVA_PLATFORM)
      ? 'https://api.mydomain.dev' : 'https://api.mydomain.com',
    url: '/',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
    },
  },
});

Then when I try to perform a $fetch operation on one of my orm models, I get "token not provided"

If I pass the token as a get query parameter then it works but I would prefer not to do that and pass it as a header.

Can I add a header to this axios plugin after it's already been initialized?

Or else what is the best practice for including an authorization header with every axios call?

Thank you..

@vesper8
Copy link
Author

vesper8 commented Jan 14, 2019

I was able to get this to work finally by using the PR provided by @Akhail here #8

I hope this gets merged soon. In the meantime I created a patch in my project using the awesome https://github.com/ds300/patch-package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant