Lekens
Lekens

Reputation: 1969

Json web token generation in angular4 or javascript

How can I generate JSon web token for a user who just login into the application in angular2/4 application

Upvotes: 1

Views: 402

Answers (3)

Pardeep Jain
Pardeep Jain

Reputation: 86740

Actually there are number of way by using you can create JSON web token for your app, for example using btoa approach , or using jwt.io etc.

But Why to generate JSON web token ?

Generally JSON web token should be generated from back end side and which is safe also, so don't try this on client side.

Upvotes: 2

Shamim
Shamim

Reputation: 703

You can't generate web token from client side. Please use https://jwt.io/ to use it in your own server side language and use https://github.com/auth0/angular2-jwt this library to consume it.

Upvotes: 2

Emad Fani
Emad Fani

Reputation: 445

generating a token is a back-end side job and angularJs should just store it and send it to server to validate user data and basically generating it in front-end isn't a good idea cos you'r key will get in people's hand and they can generate tokens with it that server will validate it as True and it will make problems and error's for application.

Upvotes: 2

Related Questions