Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token % in JSON at position 0 #76

Open
rekkisomo opened this issue Dec 2, 2017 · 2 comments
Open

Unexpected token % in JSON at position 0 #76

rekkisomo opened this issue Dec 2, 2017 · 2 comments

Comments

@rekkisomo
Copy link

I've been using jwt-simple for a while now, and it works flawlessly! Until when I need to add it to a WebSocket.

I'm getting the following error from jwt.decode(token, secret)

undefined:1
%d�ȝ������[�Ȏ���̍M��
^

SyntaxError: Unexpected token % in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.jwt_decode [as decode] (/mnt/c/Users/sledd/Desktop/stuff/Radwolf.LIVE/API/node_modules/jwt-simple/lib/jwt.js:75:21)

The token is correct, as it works with everything else. Is passport.authenticate required? if so, How would I go about adding it as a callback function rather than implementing it via app.<action>('/pth', passport.authenticate( ... ), ()=>{})?

@fsabreu
Copy link

fsabreu commented Mar 15, 2018

Can you resolve this?

I with same problem

@icetee
Copy link

icetee commented Mar 18, 2018

@rekkisomo @fsabreu
You token maybe begin JWT ..., it has to be delete.

const payload = jwt.decode(token.replace('JWT ', ''), secret)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants