Open bezreyhan opened 7 years ago
It seems that the auth headers need to be capitalized and prefixed with HTTP: 'HTTP_ACCESS_TOKEN', 'HTTP_EXPIRY' 'HTTP_UID' 'HTTP_CLIENT' 'CONTENT_TYPE'
'HTTP_ACCESS_TOKEN', 'HTTP_EXPIRY' 'HTTP_UID' 'HTTP_CLIENT' 'CONTENT_TYPE'
However, DeviseTokenAuth does not capitalize their headers or prefix them with 'HTTP': https://github.com/lynndylanhurley/devise_token_auth#token-header-format
I tried adding this gem to my grape controllers but I was getting a 401 because of how I format my headers.
401
For example, this test fails:
auth = create(:user) .create_new_auth_token .merge('CONTENT_TYPE' => 'application/json') post '/v1/test', params.to_json, auth_headers expect(last_response.status).to_not eq(401)
where auth looks like this:
{ "access-token"=>"R4lu2FG70QUhG8VYuK92Ow", "token-type"=>"Bearer", "client"=>"I9_2W0aRzt9Be8N1ZVadJw", "expiry"=>"1497999282", "uid"=>"user_email_1@test.test", "CONTENT_TYPE"=>"application/json" }
In my controller I have:
unless authenticate_user! return error!("Authorized Users only", 401) end
It seems that the auth headers need to be capitalized and prefixed with HTTP:
'HTTP_ACCESS_TOKEN', 'HTTP_EXPIRY' 'HTTP_UID' 'HTTP_CLIENT' 'CONTENT_TYPE'
However, DeviseTokenAuth does not capitalize their headers or prefix them with 'HTTP': https://github.com/lynndylanhurley/devise_token_auth#token-header-format
I tried adding this gem to my grape controllers but I was getting a
401
because of how I format my headers.For example, this test fails:
where auth looks like this:
In my controller I have: