卫星json网络令牌未正确生成

时间:2015-12-09 06:33:54

标签: laravel laravel-5 jwt satellizer json-web-token

我已将https://github.com/tymondesigns/jwt-auth与我的laravel应用程序集成。正在生成令牌,但是当添加以下行时,它们无法正确生成并且console.log()返回 - 未定义令牌

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-xxx" data-ad-slot="xxx"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

1 个答案:

答案 0 :(得分:0)

如何根据您喜欢的任何内容创建令牌

use JWTFactory;

$customClaims = ['foo' => 'bar', 'baz' => 'bob'];

$payload = JWTFactory::make($customClaims);

$token = JWTAuth::encode($payload);

您现在可以返回此令牌

您还可以链接声明..

// add a custom claim with a key of `foo` and a value of ['bar' => 'baz']
$payload = JWTFactory::sub(123)->aud('foo')->foo(['bar' => 'baz'])->make();

$token = JWTAuth::encode($payload);

可以尝试此而不是app('tymon.jwt.payload.factory')->make($customClaims);