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

Can't inject anything to jwtOptionsProvider tokenGetter config #188

Closed
xskid opened this issue Mar 22, 2019 · 2 comments
Closed

Can't inject anything to jwtOptionsProvider tokenGetter config #188

xskid opened this issue Mar 22, 2019 · 2 comments
Labels
closed:stale Issue or PR has not seen activity recently

Comments

@xskid
Copy link

xskid commented Mar 22, 2019

tokenGetter.$inject = ["options", "myService"];
export function tokenGetter (option, myService)  {
  // Skip authentication for any requests ending in .html
  if (options.url.substr(options.url.length - 5) == '.html') {
    return null;
  }
  console.log(myService);
  return localStorage.getItem('jwtKey');
}

And then

appConfig.$inject = ["$httpProvider", "jwtOptionsProvider"];
function appConfig($httpProvider, jwtOptionsProvider) {
  jwtOptionsProvider.config({
    whiteListedDomains: [
      'localhost'
    ],
    tokenGetter : tokenGetter
  });
  $httpProvider.interceptors.push('jwtInterceptor');
}

error
Cannot read property 'url' of undefined
myService is undefined

I've tried several ways, without success yet

@xskid
Copy link
Author

xskid commented Mar 22, 2019

For does with this problem, need o inject jwtInterceptorProvider and put tokenGetter.
there, not into jwtOptionsProvider.

appConfig.$inject = ["$httpProvider", "jwtOptionsProvider", "jwtInterceptorProvider"];
function appConfig($httpProvider, jwtOptionsProvider, jwtInterceptorProvider) {
  jwtOptionsProvider.config({
    whiteListedDomains: [
      'localhost'
    ]
  });
  jwtInterceptorProvider.tokenGetter = tokenGetter;
  $httpProvider.interceptors.push('jwtInterceptor');
}

Basic usage does not mention that.

@xskid xskid closed this as completed Mar 22, 2019
@xskid xskid reopened this Mar 22, 2019
@stale
Copy link

stale bot commented Oct 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

@stale stale bot added the closed:stale Issue or PR has not seen activity recently label Oct 26, 2019
@stale stale bot closed this as completed Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:stale Issue or PR has not seen activity recently
Projects
None yet
Development

No branches or pull requests

1 participant