Uber API iOS OAuth 2.0

纵饮孤独 提交于 2019-12-01 11:04:42

Yes, this is possible. I was able to configure OAuth2 for my app using Uber API. Here are step-by-step instructions:

  1. In your app, redirect to https://login.uber.com/oauth/authorize with your client_id and response_type=code in order to allow user to authorize your app.
  2. Upon successful authorization, Uber will redirect to your redirect_uri (you can specify any redirect_uri, including localhost:xxxx for testing purposes, etc.) to provide you with an auth code that is single-use and valid for 10 min. Implement a callback to retrieve this auth code.
  3. With the valid auth code from Step 2, make a POST request to exchange for an access token. As a simple check, I would recommend using curl to confirm access token validity. For ex: 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

  4. Upon successful exchange, use the access token as the value for the 'Authorization' header for subsequent endpoint calls. For ex: curl -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' 'https://api.uber.com/v1/products?latitude=37.7759792&longitude=-122.41823'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!