title: Uber Authentication failed "HTTP Status 401: Unauthorized, Response: {"error": "invalid_client"}"
body: <p>i am using <a href="https://github.com/dongri/OAuthSwift" rel="nofollow">this</a> library for Uber Authetication</p>
  
  <p><a href="https://developer.uber.com/v1/auth/" rel="nofollow">https://developer.uber.com/v1/auth/</a></p>
  
  <p>I have done like this</p>
  
  <pre><code>func doOAuthUber(){
  
  let oauthswift = OAuth2Swift(
      consumerKey:    "fXfXXXXXXXUo9vtKzobXXXXXUDO",
      consumerSecret: "e5XXXXXXXq2w63qz9szEx7uXXXXXXo03W",
      authorizeUrl:   "https://login.uber.com/oauth/authorize",
      accessTokenUrl: "https://login.uber.com/oauth/token",
      responseType:   "code"
  )
  
  var originalString = "jamesappv2://oauth/callback"
  var encodedCallBackUrl = originalString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
  
  println("encodedCallBackUrl: \(encodedCallBackUrl)")
  
  
  let state: String = ""
  oauthswift.authorizeWithCallbackURL( NSURL(string: encodedCallBackUrl!)!, scope: "request%20history", state: state, success: {
      credential, response in
  
      println(credential.oauth_token)
      self.personalDriverLoader.stopAnimating()
  
  
  
      }, failure: {(error:NSError!) -&gt; Void in
  
          self.personalDriverLoader.stopAnimating()
          println(error.localizedDescription)
  })
  
  }
  </code></pre>
  
  <p>but getting this response
  HTTP Status 401: Unauthorized, Response: {"error": "invalid_client"}</p>
  
  <p>I have triple checked that my client_id (consumerKey) and secret (consumerSecret) are correct.
  What I have done wrong here</p>
  
  <p><strong>Update:1</strong></p>
  
  <p>this is wired I changed responseType: "code" to responseType: "token" and it worked Got My access token. but I am getting an other issue now</p>
  
  <p>now when ever I try to call the <a href="https://developer.uber.com/v1/tutorials/#request" rel="nofollow">request endpoint api</a></p>
  
  <p>using below code</p>
  
  <pre><code>@IBAction func btnRequestUberdidClicked(sender: AnyObject) {
  
      self.callRequestAPI("https://sandbox-api.uber.com/v1/requests")
  
  }
  
  func callRequestAPI(url:String){
  
      var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
      var session = NSURLSession(configuration: configuration)
  
      let params:[String: AnyObject] = [
                  "product_id" : selectedUberProductId,
                  "start_latitude" : start_lat,
                  "start_longitude" : start_lng,
                  "end_latitude" : end_lat,
                  "end_longitude" : end_lng]
  
  
  
      appDelegate.oauthswift.client.post(url, parameters: params,
      success: { data, response in
  
      let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
  
  
           println("Success")
  
                      println(data)
  
                      println(response)
  
  
          }, failure: {(error:NSError!) -&gt; Void in
  
                           println("Error")
  
                      println(error)
      })
  
  
  }
  </code></pre>
  
  <p>I am getting this response</p>
  
  <pre><code>Error Domain=NSURLErrorDomain Code=401 "HTTP Status 401: Unauthorized, Response: {"message":"Invalid OAuth 2.0 credentials provided.","code":"unauthorized"}" UserInfo=0x1c563220 {NSLocalizedDescription=HTTP Status 401: Unauthorized, Response: {"message":"Invalid OAuth 2.0 credentials provided.","code":"unauthorized"}, Response-Headers=&lt;CFBasicHash 0x1c578c40 [0x35305710]&gt;{type = immutable dict, count = 7,
  entries =&gt;
      1 : x-xss-protection = &lt;CFString 0x1ae2fc60 [0x35305710]&gt;{contents = "1; mode=block"}
      4 : Server = &lt;CFString 0x1acc24c0 [0x35305710]&gt;{contents = "nginx"}
      5 : Content-Type = &lt;CFString 0x1c4d0020 [0x35305710]&gt;{contents = "application/json"}
      6 : Content-Length = &lt;CFString 0x1c4b70b0 [0x35305710]&gt;{contents = "75"}
      8 : Date = &lt;CFString 0x1c4ed4b0 [0x35305710]&gt;{contents = "Wed, 06 May 2015 12:46:51 GMT"}
      10 : Strict-Transport-Security = &lt;CFString 0x1c225cb0 [0x35305710]&gt;{contents = "max-age=31536000; includeSubDomains; preload"}
      11 : x-uber-app = &lt;CFString 0x1c49a6b0 [0x35305710]&gt;{contents = "uberex-sandbox"}
  }
  }
  </code></pre>