question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please let us allow to provide JWT_OPTIONS so that we can use DI for our tokenGetter

See original GitHub issue

How am I supposed to use services in token getter. It was possible in previous version of this module but this newer version does not allow to do that. If we are allowed to provide config option as provider then this is doable. I was expecting to do following so that I could utilize services to provide token.

export function jwtOptionsProvider(store) {
  return {
    tokenGetter() {
      let token;
      store.select('authToken').select(1).subscribe(t => token = t);
      return token;
    };
  }
}

[
  {
    provide: JWT_OPTIONS,
    useFactory: jwtOptionsProvider,
    deps: [Store]
  }
]

Angular v 4.3.1 auth0/angular-jwt v^1.0.0-beta.5

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
chenkiecommented, Jul 27, 2017

The tokenGetter is currently set up to handle a returned string value synchronously, however, support for async token fetching is coming 👍

1reaction
bisubuscommented, Aug 3, 2017

@chenkie Great, just in time, thanks for the notification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass dependencies to @auth0-angular-jwt?
This can be done by overriding config service: export const jwtOptionsFactory = (dependency) => ({ tokenGetter: () => dependency.
Read more >
Structuring token based authorisation in an Angular web app
In this article, I will talk about how you might structure your own Angular Web app to make use of this feature for...
Read more >
ASP.NET Core Authentication with JWT and Angular - Part 2
We are going to use the @auth0/angular-jwt library, to help us with JWT validation and with adding the token to the HTTP requests....
Read more >
JWT Authentication with ASP.NET Core 2 Web API, Angular 5 ...
With this role stashed in our token, we can use a claims-based authorization check to give the role access to certain controllers and...
Read more >
@auth0/angular-jwt - npm
If you have multiple tokens for multiple domains, you can use the HttpRequest passed to the tokenGetter function to get the correct token ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found