Uber Invalid OAuth 2.0 credentials provided Uber Authentication In ios Swift

后端 未结 3 499
野性不改
野性不改 2020-12-16 04:18

I\'m implementing the Uber\'s Request Endpoint in my iOS (Swift) App. The Request API/Endpoint requires the user authentication with the app, here is the doc.

For th

3条回答
  •  臣服心动
    2020-12-16 04:51

    To use the token just follow step 5 of the instructions in the OAuth2 library, like you did before you started to try to sign it yourself a second time. The request has already been signed and has the Bearer token set up, there is nothing left to do for you:

    let url = NSURL(string: "https://api.uber.com/v1/products?latitude=37.7759792&longitude=-122.41823")
    let req = appDelegate.oauth.request(forURL: url)
    
    // customize your request, if needed. E.g. for POST:
    req.HTTPMethod = "POST"
    
    // send the request
    let session = NSURLSession.sharedSession()
    let task = session.dataTaskWithRequest(req) { data, response, error in
        if nil != error {
            // something went wrong
        }
        else {
            // check the response and the data
            // you have just received data with an OAuth2-signed request!
        }
    }
    task.resume()
    

提交回复
热议问题