Calling Uber API from Rails: {"error": "invalid_client"} -


been @ day.

using rails call uber api , failing access token. grabbing authorization code works, exchanging access token not.

i've tried , without oauth 2.0 gem , made sure keys accurate. tried on 2 separate uber accounts, too. combinations give same error: {"error": "invalid_client"}.

i'll post non-oauth code below. params[:code] auth code returned 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 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 help.

  • if {"error": "invalid_client"} means sending additional http request header not required validated uber oauth provider server.
    possible reason misspelled request parameter names. (not case)

    solution: need remove authorization header request , try again, i.e. don't send http request headers.

  • if have multiple redirect urls defined in uber developers dashboard , making authentication request without 1 keep in mind first url defined in dashboard used:

    if none provided default first redirect uri provided in application's dashboard.

    and if first url doesn't match url used in the authorize step of oauth flow {"error": "access_denied"}

    however, i've noticed error raised if first url matches url sent authorize step, recommend send redirect_uri parameter @ each step of oauth flow.

    solution: need send redirect_uri parameter in request (the same used on authorize step)

  • if code inside params[:code] has been used once or has become invalid {"error": "invalid_grant"}

    solution: need redo authorize (first) step in oauth flow obtain new code need exchange access token.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -