jwt-auth: jwt malformed
Okay so I’m running laravel 5.2 and trying to generate a token that is valid on a socket.io server. However I seem to fail horrible at this, (not sure if this is a problem with me or this library) so some help would be much appreciated!
On my laravel I have some simple lines:
$user = App\User::find(1);
$token = JWTAuth::fromUser($user);
And then I use this token when making the socket io connection from the client:
var socket = io.connect('http://localhost:8085', {
'query': 'token={{$token}}'
});
Simple socketio server:
var io = require('socket.io')();
var socketioJwt = require("socketio-jwt");
io.use(socketioJwt.authorize({
secret: 'supersecretkey',
handshake: true
}));
io.on('connection', function(socket){
console.log('connected!');
});
io.listen(8085);
console.log('socketio-server listening on *:8085');
However this gives me:
{
message: "invalid signature",
code: "invalid_token",
type: "UnauthorizedError"
}
So I instead of using socketio-jwt library, I also tried interfacing it directly against jsonwebsocket which gives me invalid signature as well.
I use the same key on both places and my jwt.php config file looks like this:
<?php
return [
'secret' => 'supersecretkey',
'ttl' => 60,
'refresh_ttl' => 20160,
'algo' => 'HS256',
'user' => 'App\User',
'identifier' => 'id',
'required_claims' => ['iat', 'exp', 'nbf', 'sub', 'jti'],
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
'providers' => [
'user' => 'Tymon\JWTAuth\Providers\User\EloquentUserAdapter',
'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter',
'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter',
'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter'
]
];
So what am I missing? I also tried to decode the jwt on the https://jwt.io/ website, but that doesn’t work either. Help is very much appreciated!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (7 by maintainers)
cool story bro