Reputation: 827
I have two applications. One contains an API (Rails) and the second (Sinatra) is a test application to check if the API is working correctly. In the test application I can get all of the information provided by my API using HTTParty. However, when I try to add http basic authentication in the API application, the test application always gets a 401 error.
In the controller which provides the API I have written
http_basic_authenticate_with name: "admin", password: "admin"
In my test application I have written
authenticate = {name: "admin", password: "admin"}
options = {query: {username: params[:username], email: params[:email]},
basic_auth: authenticate}
response = HTTParty.get('http://localhost:3000/search.json', options)
What am I doing wrong?
Upvotes: 2
Views: 1776
Reputation: 5015
Your key for the username is incorrect:
authenticate = {:username => 'admin', :password => 'admin'}
This should work
Upvotes: 2