Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Authentication token is missing #352
So have been hacking away on this problem since yesterday...and I can't seem to find the problem here. I was wondering if you guys might have some tips as to how I can further debug this issue.
I have a feathers-rest service setup with some of the endpoints that I restricted with the feathers-authentication hooks. Now when I login I do receive the JWT token, but when I use this token to authenticate the action I got an Error message back that says the following "message":"Authentication token missing.". I send the token via the HTTP authorization header as specified by my config file. And I have checked XHR request header to see if the token is been send. And everything seems fine. So I don't know why the verifyToken() hook sends back the missing token message.
here is an example output of a console log on my feathers app's settings.auth
I can send you guys further gist and any information you guys need, but I am happy enough to fix my own issues. It is just I do not know how to further debug this problem. Any tips?
So have made some progress on the issue. I have hacked around on the source code for feathers-authentication looking for the source of the problem. So the error message is generated in the /lib/hooks/verify-token.js on line 21. it appears it is looking for the token in the hook.params.token. So I have console.log the variable and it appears to be undefined. I am sending my token via the http headers using axios. The reason I am not using feathers-client is that the service is a stand-alone service on a separate server so it needs to work via XHR request...for client purposes. So using feathers-client is not a solution. So how do get the token into hook.params without actually posting through form data?
I have manage to sort out the issue. I rearranged the order in which my feathers app was configured. I moved my feathers-rest and feathers-hooks config before the body parser thanks to the tip from one of my senior developers. It seems that the body parser might of been eating up my authorisation header. Not sure how though but everything seems to work after reordered the way the app was configured.