Node-jsonwebtoken: JsonWebTokenError: jwt malformed

Created on 27 Mar 2017  路  3Comments  路  Source: auth0/node-jsonwebtoken

I am getting this error when I try and verify.

var decoded = jwt.verify(req.headers.authorization, "12345");

req.headers.authorization is giving me this value: Basic TGlua1NoYWRlc0FsZXhhOjEyMzQ1

I've tried this as well but get the same error:

var decoded = jwt.verify(req.headers.authorization.split(' ')[1]), "12345");

Any ideas?

question

Most helpful comment

@glowlabs without knowing further details, it seems the requester is using Basic authentication scheme.

That is not a JWT, it is a base64 string containing "username:password".

Usually people use Bearer scheme with JWT as token. Anyway, you need to create the token by calling first jwt.sign().

All 3 comments

@glowlabs without knowing further details, it seems the requester is using Basic authentication scheme.

That is not a JWT, it is a base64 string containing "username:password".

Usually people use Bearer scheme with JWT as token. Anyway, you need to create the token by calling first jwt.sign().

i am getting this type of error after running POST request

{
"name": "NotAuthenticated",
"message": "jwt malformed",
"code": 401,
"className": "not-authenticated",
"data": {
"name": "JsonWebTokenError",
"message": "jwt malformed"
},
"errors": {}
}

any ref for username/password authentication?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rynbyjn picture rynbyjn  路  5Comments

mathellsmelo picture mathellsmelo  路  3Comments

ehartford picture ehartford  路  3Comments

prevostc picture prevostc  路  4Comments

samholmes picture samholmes  路  5Comments