0

Currently, I am running Angular 1.6.6. and Angular-jwt 0.1.9. I am following the examples from the READ.me file of Angular-jwt as well from the auth0 site here "How can I send the JWT on every request to the server?". The two examples vary slightly. The angular-jwt docs uses jwtOptionsProvider and the auth0 example uses jwtInterceptorProvider in the .config section for the angular controller.

When I run this code the browser console states:

"Failed to instantiate module controllerName due to: Error: [$injector:unpr] 
Unknown provider: jwtInterceptorProvider"

The error is the same for jwtInterceptorProvider and jwtOptionsProvider. Here the code in the angular controller, which is the same as from the docs. I am wanting to just make this code run so that I can understand how to use it:

angular
  .module('app', ['angular-jwt'])
  .config(function Config($httpProvider, jwtOptionsProvider) {
      jwtOptionsProvider.config({
      tokenGetter: ['myService', function(myService) {
      myService.doSomething();
      return localStorage.getItem('id_token');
      }]
 });

   $httpProvider.interceptors.push('jwtInterceptor');
 })

Can someone explain why this error is occurring and how to correct it?

Val
  • 1,260
  • 5
  • 23
  • 39
  • 1
    Did you take a look at their last [jsfiddle](http://jsfiddle.net/mgonto/my5dgktj/)? You should probably just use that as a guide. The readme basic usage will need you to setup a service to follow it, and it's not as straightforward. Make sure you have your angular-jwt.js correctly linked in your project just like their jsfiddle has it as an external resource. – syciphj Sep 14 '17 at 02:43
  • After your post - yes. It appears the error can be corrected if one reverts back to angularjs v1.2.1 (as shown the jsfiddle). Unfortunately, I'm using other angular resources that require newer versions of angular. These latest version appears not compatible with jwtInterceptor from the angular-jwt dependancy. This seems a bit odd since angular uses this with their auth0 services. – Val Sep 14 '17 at 03:58

0 Answers0