Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INVALID_SIGNATURE with Swift 3 Xcode 8 beta 6 #41

Closed
mittonk opened this issue Aug 25, 2016 · 7 comments
Closed

INVALID_SIGNATURE with Swift 3 Xcode 8 beta 6 #41

mittonk opened this issue Aug 25, 2016 · 7 comments

Comments

@mittonk
Copy link

mittonk commented Aug 25, 2016

@cambuilt writes in Yelp/yelp-api#165 :

I consistently get this error using OAuthSwift with different branches and forks. However, in Xcode 7.3 with Swift 2.0, I have no problem.

Anybody else having this issue?

@mittonk
Copy link
Author

mittonk commented Aug 25, 2016

@cambuilt : Could you provide more of the error response (but not your private credentials)? Might help narrow things down.

@d9chen : Might be worth setting up XCode 8 to check this out.

@SSheldon
Copy link
Member

@cambuilt, you aren't using YelpAPI, are you? We don't use OAuthSwift in YelpAPI, I assume you've written your own code for authenticating with our api and this is an error you're hitting in that?

@SSheldon
Copy link
Member

@cambuilt, it looks like OAuthSwift doesn't officially support Swift 3 yet: OAuthSwift/OAuthSwift#244. You'll probably want to wait to use Swift 3 until they're ready.

@cambuilt
Copy link

This is my fork of the code I changed to build in Xcode 8 beta 6:

https://github.com/cambuilt/OAuthSwift/tree/master/OAuthSwift https://github.com/cambuilt/OAuthSwift/tree/master/OAuthSwift

This is the code using OAuthSwiftClient:

    let clientYelp = OAuthSwiftClient(consumerKey: yelpConsumerKey, consumerSecret: yelpConsumerSecret, accessToken: yelpToken, accessTokenSecret: yelpTokenSecret)

    _ = clientYelp.get(baseUrl, parameters: param2, success: { (data, response) in
        do {
            if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? NSDictionary {
                CoreSearch.loadYelpSearchResults(jsonResult: json)
            } else {
                CoreSearch.finishFailedYelpSearch()
            }
        } catch {
            print("Yelp search error: \(error)")
        }
    }) { (error) in
        print("Yelp search error: \(error)")
    }

This is the error:

Error Domain=NSURLErrorDomain Code=400 "" UserInfo={NSErrorFailingURLKey=Optional("http://api.yelp.com/v2/search?offset=0&radius_filter=10000.0&ll=40.7830335501822%2C-124.161309&category_filter=restaurant"), NSLocalizedDescription=, Response-Headers={
"CF-RAY" = "2d838219851f0f33-IAD";
"Cache-Control" = private;
Connection = "keep-alive";
"Content-Length" = 512;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Fri, 26 Aug 2016 01:28:38 GMT";
Server = "cloudflare-nginx";
"Set-Cookie" = "__cfduid=d5cc40717d5e8eee53bdfa4019a12ee821472174918; expires=Sat, 26-Aug-17 01:28:38 GMT; path=/; domain=.yelp.com; HttpOnly, bse=94c1838ba363e3dba995f324844e6eaf; Domain=.yelp.com; Path=/; HttpOnly, yuv=eqNhoOov9xBwf1RS4V8luh8Hy8_QX0vRMmplYHsJB5TfNPMDioNFq8mkFXqkqdLVsE5I7ELZk2zOKPxIibCW18f58LVS7w0r; Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Thu, 21-Aug-2036 01:28:38 GMT";
Vary = "User-Agent";
"X-Mode" = ro;
"X-Node" = "api_com, web94-r6-iad1";
"X-Proxied" = "extlb3-r8-iad1";
}, Response-Body=Optional("{"error": {"text": "Signature was invalid", "id": "INVALID_SIGNATURE", "description": "Invalid signature. Expected signature base string: GET\u0026http%3A%2F%2Fapi.yelp.com%2Fv2%2Fsearch\u0026category_filter%3Drestaurant%26ll%3D40.7830335501822%252C-124.161309%26oauth_consumer_key%3DPlNDBy28JaUPEOqBXMIn-Q%26oauth_nonce%3DC0DD55C0%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1472174918%26oauth_token%3D8yJiBcyUjG8-56JWD1fdF8QciG8FBQA2%26oauth_version%3D1.0%26offset%3D0%26radius_filter%3D10000.0"}}"), oauthswift.error.response=<NSHTTPURLResponse: 0x618000423660> { URL: http://api.yelp.com/v2/search?offset=0&radius_filter=10000.0&ll=40.7830335501822%2C-124.161309&category_filter=restaurant } { status code: 400, headers {
"CF-RAY" = "2d838219851f0f33-IAD";
"Cache-Control" = private;
Connection = "keep-alive";
"Content-Length" = 512;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Fri, 26 Aug 2016 01:28:38 GMT";
Server = "cloudflare-nginx";
"Set-Cookie" = "__cfduid=d5cc40717d5e8eee53bdfa4019a12ee821472174918; expires=Sat, 26-Aug-17 01:28:38 GMT; path=/; domain=.yelp.com; HttpOnly, bse=94c1838ba363e3dba995f324844e6eaf; Domain=.yelp.com; Path=/; HttpOnly, yuv=eqNhoOov9xBwf1RS4V8luh8Hy8_QX0vRMmplYHsJB5TfNPMDioNFq8mkFXqkqdLVsE5I7ELZk2zOKPxIibCW18f58LVS7w0r; Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Thu, 21-Aug-2036 01:28:38 GMT";
Vary = "User-Agent";
"X-Mode" = ro;
"X-Node" = "api_com, web94-r6-iad1";
"X-Proxied" = "extlb3-r8-iad1";
} }, oauthswift.error.response.data=<7b226572 726f7222 3a207b22 74657874 223a2022 5369676e 61747572 65207761 7320696e 76616c69 64222c20 22696422 3a202249 4e56414c 49445f53 49474e41 54555245 222c2022 64657363 72697074 696f6e22 3a202249 6e76616c 69642073 69676e61 74757265 2e204578 70656374 65642073 69676e61 74757265 20626173 65207374 72696e67 3a204745 545c7530 30323668 74747025 33412532 46253246 6170692e 79656c70 2e636f6d 25324676 32252016-08-25 21:28:45.353083 camtinerary[2423:70753] [Client] Geocode error: Error Domain=GEOErrorDomain Code=-8 "(null)"
3246 73656172 63685c75 30303236 63617465 676f7279 5f66696c 74657225 33447265 73746175 72616e74 2532366c 6c253344 34302e37 38333033 33353530 31383232 25323532 432d3132 342e3136 31333039 2532366f 61757468 5f636f6e 73756d65 725f6b65 79253344 506c4e44 42793238 4a615550 454f7142 584d496e 2d512532 366f6175 74685f6e 6f6e6365 25334443 30444435 35433025 32366f61 7574685f 7369676e 61747572 655f6d65 74686f64 25334448 4d41432d 53484131 2532366f 61757468 5f74696d 65737461 6d702533 44313437 32313734 39313825 32366f61 7574685f 746f6b65 6e253344 38794a69 42637955 6a47382d 35364a57 44316664 46385163 69473846 42514132 2532366f 61757468 5f766572 73696f6e 25334431 2e302532 366f6666 73657425 33443025 32367261 64697573 5f66696c 74657225 33443130 3030302e 30227d7d>}

On Aug 25, 2016, at 6:37 PM, Ken Mitton notifications@github.com wrote:

@cambuilt https://github.com/cambuilt : Could you provide more of the error response (but not your private credentials)? Might help narrow things down.

@d9chen https://github.com/d9chen : Might be worth setting up XCode 8 to check this out.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #41 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ALClF9WISGmFGb6oJDggcesxVSiMz1I2ks5qjhlEgaJpZM4JtklA.

@cambuilt
Copy link

You’re probably right and I am not using YelpAPI.

On Aug 25, 2016, at 7:07 PM, Steven Sheldon notifications@github.com wrote:

@cambuilt https://github.com/cambuilt, it looks like OAuthSwift doesn't officially support Swift 3 yet: OAuthSwift/OAuthSwift#244 OAuthSwift/OAuthSwift#244. You'll probably want to wait to use Swift 3 until they're ready.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #41 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ALClF0ItLVfXia4reipuNA4aj1ovwX0cks5qjiAsgaJpZM4JtklA.

@cambuilt
Copy link

Sorry, I gave you my credentials and I will generate new ones.

On Aug 25, 2016, at 6:37 PM, Ken Mitton notifications@github.com wrote:

@cambuilt https://github.com/cambuilt : Could you provide more of the error response (but not your private credentials)? Might help narrow things down.

@d9chen https://github.com/d9chen : Might be worth setting up XCode 8 to check this out.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #41 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ALClF9WISGmFGb6oJDggcesxVSiMz1I2ks5qjhlEgaJpZM4JtklA.

@SSheldon
Copy link
Member

Hey @cambuilt, I checked out your branch and it looks like you've made lots of changes to OAuthSwift for updating it to Swift 3. We haven't worked with OAuthSwift so I'm not sure there's much more we can do to help, sorry! I think your best bet might be to wait on OAuthSwift/OAuthSwift#267 getting merged and seeing if OAuthSwift still has this issue.

If you want to keep debugging OAuthSwift, @mittonk mentioned that common issues people run into with OAuth include:

  • Mishandling of Unicode params that then get OAuth signed
  • too-old or too-new libraries
  • wrong creds

Hope that helps!

I'd also recommend giving this YelpAPI library a shot, it's available on CocoaPods and is Swift compatible! If you run into any issues using it we'll be able to assist in resolving those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants