R
R
Ramil992016-09-07 23:49:11
JSON Web Token
Ramil99, 2016-09-07 23:49:11

How to use angular2-jwt?

Guys, tell me please.
There is such a thing as angular2-jwt . Is it possible to use this without including the dev library which is auth0 and their lock widget? Or is angular2jwt specifically designed to work for them? They didn’t ban me in Google, but I didn’t find an adequate use case without registering on the Auth0 service.
Maybe someone used and can throw off links to examples? Do they have everything here using the above?
Is there any other way to work with tokens in angular2?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-09-08
@Ramil99

Is it possible to use this without including the developer library

Yes. Liba is self-sufficient.
There, everything in the readme is basically described as what to use.
import { tokenNotExpired, JWTHelper } from 'angular2-jwt';

const token = 'some jwt token';
const jwtHelper = new JWTHelper;

if (tokenNotExpired(token)) {
    // everything ok
}

const payload = jwtHelper.decodeToken(token);

this is the minimum set of features. There's more out there, Http service integration, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question