mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 20:55:57 +03:00
[GH-ISSUE #80] POST request Authentication Failed #51
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#51
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 @gabriel-jones on GitHub (Jul 6, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/80
I am trying to upload a piece of data to Intuit's Quickbooks API, by doing something like this:
But I get back an error from the server saying the content type is not valid. So I tried changing (in the OAuthSwiftClient) where it says
request.encodeParameters = truetorequest.encodeParameters = false, and this gives me the error from the server saying the application's authentication failed, and the OAuth signature is not included in the response string.I should probably add that doing a GET request works fine.
Has anybody else had these problems?
@phimage commented on GitHub (Aug 7, 2015):
You set
request.encodeParameters = falsein framework code to force encode json (and add json header), code maybe not reachable without hacking the framework...For OAuth v1 there is a method
OAuthSwiftClient.authorizationHeaderForMethodI think your json is merged into the Authorization header, so the website does'nt understand anything
You can test by modifying other code into
OAuthSwiftClientreplace
parametershere with empty dictionnary@gabriel-jones commented on GitHub (Sep 2, 2015):
@phimage Could you give an example of all changes to the request function in OAuthSwiftClient?
@phimage commented on GitHub (Sep 2, 2015):
I am just taking about one little change already described upper with function name and line of code
empty dico : Dictionary<String, AnyObject>()
instead of parameters
@gabriel-jones commented on GitHub (Sep 3, 2015):
@phimage This throws the error 400: Bad Request:
oauth_problem=parameter_absent&oauth_parameters_absent=oauth_callbackFor when it tries to redirect to login page, not even to post request yet.
@gabriel-jones commented on GitHub (Sep 3, 2015):
@phimage So I reviewed it with Intuit support and everything seems fine. They suspect the problem is with the HTTP body not being encoded before the signature is generated. Is this a problem with the framework, and has anybody had difficulty with POST requests before?
@olivier38070 commented on GitHub (Sep 28, 2015):
Hi,
on my side, with smugmug (I don't have account elsewhere to test), POST and PUT are not working.
I obtain always invalid signature feedback.
I tried to change the url, the parameter, and did a lot of test, without any success.
@janakmshah commented on GitHub (Nov 9, 2015):
Did anyone find a fix for this?
@phimage commented on GitHub (Nov 19, 2015):
No fix currently
There is some confusion between query URL parameters and HTTP Body
If POST, parameters become "body" but also used in authentification signature, like parameters was in query (so we have a wrong signature)
Then encodeParameters is always true so there is never json content type (maybe I will remove that and check if content type added)
I can provide some network code not tested yet (you could use also other remote framework like alamofire)
@phimage commented on GitHub (Nov 22, 2015):
For inuit oauth_body_hash is maybe necessasy to sign JSON or XML posted body http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
@gabriel-jones commented on GitHub (Nov 22, 2015):
Is this something you could add to the library? If so that would be great
@phimage commented on GitHub (Nov 23, 2015):
Yes but I have no time this week and maybe not the next one.
This is not easy because OAuthSwift create the header before filling the body, there is some change to do (maybe fill body before, or extract a body creation only function)
@phimage commented on GitHub (Nov 25, 2015):
No need for body hashing, I have done a POST request with success on Inuit sandbox
For that, add headers to encode in JSON body and remove
parametersfrom signatureI add an example in demo app for inuit
XML is not supported yet, new issue(feature, enhancement) for it if necessary
two solution:
parametersparametersto XML (not available in Foundation I think, so user must configure an handler to encode according to encode type)