tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.32k stars 1.54k forks source link

How to get created Token #1134

Open karmamaster opened 7 years ago

karmamaster commented 7 years ago

Hello, Can I get tokens which created by JWT-Auth? I have tried to look at google but no luck to me.

Thanks

jonagoldman commented 7 years ago

Can you explain a bit more? Have you looked at https://github.com/tymondesigns/jwt-auth/wiki/Creating-Tokens

karmamaster commented 7 years ago

Yes, I took a look in jwt-auth Wiki. My question means: I want to get the token currently available on server. But can you told me how can I get the content of token string like this website: jwt.io?

gouravnema commented 7 years ago

Yes, I took a look in jwt-auth Wiki. My question means: I want to get the token currently available on server.

jwt tokens are not stored anywhere. they are just validated against the payload and shared secret.

But can you told me how can I get the content of token string like this website: jwt.io?

https://github.com/tymondesigns/jwt-auth/wiki/Creating-Tokens#creating-a-token-based-on-anything-you-like

jonagoldman commented 7 years ago

Well, as I said, to get a token like you see in that website you use one of the methods provided by this package:

$token = JWTAuth::attempt($credentials)
// or
$token = JWTAuth::fromUser($user);
// or
$token = JWTAuth::encode($payload);

but again, I get the feeling you don't completely understand how JWT works and you didn't read the docs. JWT is stateless, it is not saved in the database automatically for you, you can if you want but thats not the point of it.