Angular2-jwt: JwtModule not attaching authorization token in request

Created on 9 Sep 2019  ·  8Comments  ·  Source: auth0/angular2-jwt

I have configured JwtModule in my Angular app. According to documentation 'Any requests sent using Angular's HttpClient will automatically have a token attached as an Authorization header.' But it's not working ... Can you please check and test the repositories code again?

stale

All 8 comments

I'm having the same problem. @mdhelaluddin-ctg-bd have you gotten anywhere with it?

@mdhelaluddin-ctg-bd @circuitBurn Could you share a repro where we can take a look?

@stevehobbsdev I have this same issue.
Here is my repo:
https://github.com/BartoszBartniczak/todo-angular/tree/jwt

If you need API app, here it is:
https://github.com/BartoszBartniczak/symfony-todo-app/tree/jwt

I have the same issue. Any solution ?

m having the

Nope. Didn't find any solution.

@mdhelaluddin-ctg-bd I've noticed in your code that you're using a full origin value in the whitelist array: https://github.com/BartoszBartniczak/todo-angular/blob/jwt/src/app/app.module.ts#L58

Can you try just setting it as todo-api.test (without the scheme) and see if that works for you?

@stevehobbsdev Your tip was realy helpfull, although it didn't fix the bug at the begining:
image

I needed to change the nginx config and add Authorization as accepted header:
'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';

But after that change I couldn't log in:
image

I changed the blacklistedRoutes:

blacklistedRoutes: [
          'todo-api.test/login_check',
        ],

which seems to be correct, with documentation, but still doesn't work.

When I turned off the throwNoTokenError option, everything started to work, which is a little bit weird.

It looks like, it tries to get token before checking blacklisted routes.

Thank you for your help. Everything working fine right now.

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! 🙇‍♂️

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kolkov picture kolkov  ·  3Comments

UlyssesAlves picture UlyssesAlves  ·  5Comments

leosvelperez picture leosvelperez  ·  5Comments

n0490b picture n0490b  ·  4Comments

tekkudoc picture tekkudoc  ·  5Comments