-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
401 unauthorized #193
Comments
Hi @milesmatthias - here are a few things to check:
Also, I'll be releasing a jQuery version of ng-token-auth tomorrow or Friday. I'm not sure if you can wait until then, but that might be easier than building everything out from scratch. |
thanks for the response @lynndylanhurley. I commented out the
also, the following works inside my pry:
and yet when I undo my above changes and run it like normally, I get:
So why is authenticate_user! failing? Maybe it's because I'm also running devise side by side? I thought by including |
@lynndylanhurley any tips on this? |
@milesmatthias - have you tried sending the auth credentials as headers instead of post-body params? Or can you at least check to see if there are any conflicting headers being sent? It will try to use the headers first, then the params if the headers aren't found. Also, I finished the jQuery plugin today. I'll release it tomorrow as soon as I finish the demo site and documentation. |
@lynndylanhurley I just tried that and it's still not working. |
@milesmatthias - I've finished the jQuery version of ng-token-auth, but I haven't set the repo to public yet. Would you like to try it out? I can give you access to the repo if you like. |
@lynndylanhurley Sure, that would be cool. |
Alright I just pushed everything live: https://github.com/lynndylanhurley/j-toker To install: # using bower:
bower install j-toker --save
# using npm:
npm install j-toker --save |
@lynndylanhurley very creative 'MOTD' as usual :) |
Cool, thanks @lynndylanhurley. I'll check it out! |
@lynndylanhurley I tried your plugin and I'm getting the same results. I'm able to authenticate, but successive requests to any custom API endpoints fail. Here's a screenshot of the request headers sent to my /api/v1/projects endpoint: https://s3.amazonaws.com/screenshots.equityeats.com/qerZy.png |
Your UID is null. Should be your email. |
I saw that too @nicolas-besnard. I think that means the j-token plugin has an issue in it? |
I updated the devise_token_auth gem from 0.1.29 to 0.1.30 and this is working now with the jQuery j-token plugin. |
I'm not using Angular.js, so the demo code isn't very helpful. On a very basic level, the idea is to post an email and password to
sign_in
and then send theaccess-token
,uid
, andclient
along with each successive call, right? Well I'm able to authenticate successfully, but when I make another call to a sample endpoint that usesbefore_filter :authenticate_user!
, I always get a 401 unauthorized.Here's my test code:
api/projects_controller.rb
:I narrowed it down to
valid_token?
(https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/concerns/set_user_by_token.rb#L40) always returning false, even though that user has several tokens.What am I missing here? Thanks!
The text was updated successfully, but these errors were encountered: