[GH-ISSUE #187] Withings server does not process the oauth parameters sent in Authorization header #112

Closed
opened 2026-03-03 16:45:48 +03:00 by kerem · 0 comments
Owner

Originally created by @jdrevet on GitHub (Feb 19, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/187

If we send a request to Withings API to access any resources, the server returns an error :

{
    body =     {
    };
    error = "Not enough params";
    status = 503;
}

I have used the following code to send the request with the demo app :

func doOAuthWithings(serviceParameters: [String:String]){
        let oauthswift = OAuth1Swift(
            consumerKey:    serviceParameters["consumerKey"]!,
            consumerSecret: serviceParameters["consumerSecret"]!,
            requestTokenUrl: "https://oauth.withings.com/account/request_token",
            authorizeUrl:    "https://oauth.withings.com/account/authorize",
            accessTokenUrl:  "https://oauth.withings.com/account/access_token"
        )
        oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/withings")!, success: {
            credential, response, parameters in
            self.showTokenAlert(serviceParameters["name"], credential: credential)
            self.testWithings(oauthswift, userId: parameters["userid"]!)
            }, failure: { error in
                print(error.localizedDescription)
        })
    }
    func testWithings(oauthswift: OAuth1Swift, userId : NSString) {
        //oauthswift.client.parameterTransmissionMethod = .RequestURIQuery
        oauthswift.client.get("https://wbsapi.withings.net/v2/measure", parameters: ["action":"getactivity", "userid":userId, "date":"2016-02-15"],
            success: {
                data, response in
                let jsonDict: AnyObject! = try? NSJSONSerialization.JSONObjectWithData(data, options: [])
                print(jsonDict)
            }, failure: { error in
                print(error.localizedDescription)
        })
    }

It appears that the Withings server does not process the oauth parameters sent in Authorization header but wait for them in the request parameters.
It is not usual but it is compliant with the RFC 5849 which defines 3 differents ways to transmit the oauth parameters.

I have forked the repository to make a fix and I will submit a PR soon.

  • OS targeted (with version): iOS 9.2
  • OAuth provider: Withings (OAuth1.0)
  • OAuthSwift version: master head
Originally created by @jdrevet on GitHub (Feb 19, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/187 If we send a request to Withings API to access any resources, the server returns an error : ``` { body = { }; error = "Not enough params"; status = 503; } ``` I have used the following code to send the request with the demo app : ``` func doOAuthWithings(serviceParameters: [String:String]){ let oauthswift = OAuth1Swift( consumerKey: serviceParameters["consumerKey"]!, consumerSecret: serviceParameters["consumerSecret"]!, requestTokenUrl: "https://oauth.withings.com/account/request_token", authorizeUrl: "https://oauth.withings.com/account/authorize", accessTokenUrl: "https://oauth.withings.com/account/access_token" ) oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/withings")!, success: { credential, response, parameters in self.showTokenAlert(serviceParameters["name"], credential: credential) self.testWithings(oauthswift, userId: parameters["userid"]!) }, failure: { error in print(error.localizedDescription) }) } func testWithings(oauthswift: OAuth1Swift, userId : NSString) { //oauthswift.client.parameterTransmissionMethod = .RequestURIQuery oauthswift.client.get("https://wbsapi.withings.net/v2/measure", parameters: ["action":"getactivity", "userid":userId, "date":"2016-02-15"], success: { data, response in let jsonDict: AnyObject! = try? NSJSONSerialization.JSONObjectWithData(data, options: []) print(jsonDict) }, failure: { error in print(error.localizedDescription) }) } ``` It appears that the Withings server does not process the oauth parameters sent in Authorization header but wait for them in the request parameters. It is not usual but it is compliant with the [RFC 5849](https://tools.ietf.org/html/rfc5849#section-3.5) which defines 3 differents ways to transmit the oauth parameters. I have forked the repository to make a fix and I will submit a PR soon. - **OS targeted (with version):** iOS 9.2 - **OAuth provider:** Withings (OAuth1.0) - **OAuthSwift version:** master head
kerem closed this issue 2026-03-03 16:45:48 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#112
No description provided.