Uber API iOS OAuth 2.0

I was trying to make an iOS that would use the Uber API to do things like rides and what not. I am trying to implement OAuth 2.0 on iPhone without using any server side help.

Is it possible? Has anyone done this?

Here are some links:

Uber Authentication: https://developer.uber.com/v1/auth/

Oauth 2.0: https://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified

+2


source to share


1 answer


Yes it is possible. I was able to set up OAuth2 for my app using the Uber API. Below are step by step instructions:



  • In your app, redirect https://login.uber.com/oauth/authorize with client_id and response_type=code

    to allow the user to authorize your app.
  • After successful authorization, Uber will redirect yours redirect_uri

    (you can specify any redirect_uri including localhost: xxxx for testing purposes, etc.) to provide you with an authorization code that is one-time and valid for 10 minutes, Implement a callback to get this code authentication.
  • With valid authentication code in step 2, make a POST request to exchange an access token. As a simple check, I would recommend using curl to validate the access token. For example: curl -F 'client_secret=YOUR_CLIENT_SECRET' \ -F 'client_id=YOUR_CLIENT_ID' \ -F 'grant_type=authorization_code' \ -F 'redirect_uri=YOUR_REDIRECT_URI' \ -F 'code=AUTHORIZATION_CODE' \ https://login.uber.com/oauth/token

  • If the exchange is successful, use the access token as the value for the Authorization header for subsequent calls to the endpoints. For example: curl -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' 'https://api.uber.com/v1/products?latitude=37.7759792&longitude=-122.41823'

+7


source







All Articles