I'm trying to build a rails API and I'm using devise_token_auth gem for user authentication using tokens.
I managed to set everything up correctly and just bumped into a problem. Whenever I try to reset my password I get a 401 Unauthorized error from the API.
The flow is as follows:
My problem occurs between step 8 and 9, where I get a 401 Unauthorized response. Why is that? What can I do to solve this issue?
EDIT:
From the documentation and threads regarding this issue, I realized it has to do with headers. I do not know, however, how to manage headers on a request using Ruby on Rails.
EDIT2:
I managed to figure out where the problem lies. I need to pass access-token, client and uid as headers. I have access to that information and I'm trying to set the request headers by doing the following:
http = Net::HTTP.new("127.0.0.1", "3000")
request = Net::HTTP::Put.new("/api/v1/auth/password")
request.add_field('uid', @@sens_pms["uid"])
request.add_field('client', @@sens_pms["client_id"])
request.add_field('access-token', @@sens_pms["token"])
response = http.request(request)
However, a new problem came up when I do this. The server (API) application throws the following error:
ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow)
Important information: I'm doing this in a development environment (no nginx, just webrick)
Ok so actually i overcame
You must fill out the fields labeled 'Password' and 'Password confirmation
I did update header
with
'Authorization': 'Basic ',
'Content-Type' : 'application/json',
"token-type" : 'Bearer',
'access-token' : token,
'expiry':'XXXXX',
'client':'XXXXX',
'uid':'XXXXX',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With