Been at this for a day.
Using Rails to call the Uber API and failing to get an access token. Grabbing the authorization code works, but exchanging for an access token does not.
I've tried with and without the OAuth 2.0 gem and made sure all my keys were accurate. Tried on two separate Uber accounts, too. All combinations give the same error: {"error": "invalid_client"}
.
I'll post the non-OAuth code below. params[:code]
is the auth code returned from Uber.
uri = URI.parse('https://login.uber.com/oauth/v2/token')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
headers = {
# authentication content-type is not json
# 'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Token ' + @server_token
}
request = Net::HTTP::Post.new(uri.path, headers)
request.set_form_data({
'client_id' => @client_id,
'client_secret' => @client_secret,
'grant_type' => 'authorization_code',
'code' => params[:code]
})
response = https.request(request)
render :json => response.body
Thanks in advance for the help.