mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #95] Uber Authentication Fails with HTTP Status 401: Unauthorized, Response: {"error": "invalid_client"} #63
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#63
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sephethus on GitHub (Aug 24, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/95
OAuthSwift is incompatible with Uber's API and here is why. See my code below and the explanation for why following.
See step three, get an Access token: https://developer.uber.com/v1/auth/
This is where it fails.
I traced this all the way to the NSURLConnection point and beyond this I have no way to figure out what it's doing or what's not being sent or included. The client ID most definitely makes it all the way to the end. I found that the headers for me look like this:
Value: OAuth oauth_consumer_key="", oauth_nonce="99F7307C", oauth_signature="HPM9Yfsa54maDehZYJsIDcUQLwY%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1440433137", oauth_version="1.0"
It's supposed to be called "client ID not oauth_consumer_key so this may or may not be the issue.
One thing is for certain, the problem is fixed by commenting out the addition of headers inside the makeRequest() method in OAuthSwiftHTTPRequest.swift
These headers are needed for other API's however, and I am connecting with other API's as well. So this is not a good solution, but rather a big problem. Some code may need to be added somewhere in order to determine whether this is an Uber request or not.
@sephethus commented on GitHub (Aug 24, 2015):
Temporary fix by replacing code in makeRequest method inside OAuthSwiftHTTPRequest.swift with the following:
@phimage commented on GitHub (Aug 25, 2015):
headers are mandatory to connect
disable it here is not the solution
a better place is request method of OAuthSwiftClient class (also multiPartRequest, code must be factorized here)
this is where headers are created
And don't put "uber" string into your api, think about a generic solution like adding a Set of string in OAuthSwiftClient named noHeaderHost
But I think there is another problem
Your headers seem to be oauth1, maybe same issue https://github.com/dongri/OAuthSwift/issues/94
I will add code to this issue that you can test, and then in two day make a PR...
@sephethus commented on GitHub (Aug 25, 2015):
No, they aren't mandatory to connect apparently, because I get a token and it authenticates ONLY if I take the headers out. My headers are OAuth2. I'm using OAuth2Swift as you can see above. Plus, as you said, postOAuthAccessTokenWithRequestTokenByCode gets called, therefore OAuth2 is set to true.
@phimage commented on GitHub (Aug 25, 2015):
No your header is not OAuth2....postOAuthAccessTokenWithRequestTokenByCode has not been called
Just read your header : oauth_version="1.0"
Don't mix multiple try
And the uber return "access_token" not "code" so same as #94
Then don't mix header and query parameters
There is client id in query parameters
Then see "STEP FOUR: USE BEARER TOKEN" in uber doc, header is used to authentificate request
@sephethus commented on GitHub (Aug 25, 2015):
Why is that happening? I'm using OAuth2Swift when creating the object, not OAuth1Swift.
I also can put
println("postOAuthAccessTokenWithRequestTokenByCode is being called")inside of that method and it prints to the debug console.@dongri commented on GitHub (Aug 26, 2015):
Hi @sephethus @phimage
I Resolved Uber OAuth problem
https://github.com/dongri/OAuthSwift/pull/96/files
Thanks!
@dongri commented on GitHub (Aug 26, 2015):
Uber Wiki
https://github.com/dongri/OAuthSwift/wiki/Uber