I have already created a basic authentication key, now I am just trying to utilize it. I have tried a few different variations, but none seem to show Authorization in the request headers.
$auth = 'Basic cmFtZXNoQHVzYW1hLmNvbTpyYW1lc2h1JEBtcA=='
@response = resource.post('Authorization' => $auth)
nor
@response = resource.post(:authorization => $auth)
nor
@response = resource.post(:Authorization => $auth)
nor
@response = resource.post(:content_type => :json, :accept => :json, :headers => { 'Authorization:' => $auth })
Unfortunately I am not finding a lot of info in the rdoc that can help me solve this. Does anyone have experience adding auth headers using the Rest Client gem?
Base64.encode64
inserts newlines if the username and password are very long. To avoid that, you can either add.gsub(/\n/, '')
or useBase64.strict_encode64
. – Metacenter