I've been playing with OAuth today and I implemented it on my API. So far I was consuming the services of my API with an iPhone app and I still want to do that but since I added OAuth it is getting harder to use it and I'm facing some problems.
Here is what I have :
Here is what I can do without any problems :
And when I'm trying to change this token to an access token I have an error :
OAuthException2: Signature verification failed (HMAC-SHA1)
It seems that I'm missing something somewhere but I can't find what ! Here is something else that I found in the logs that can be helpful :
Received from consumer :
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-us
Authorization: OAuth realm="", oauth_consumer_key="55af183bbbc2c386de3d0cb82a8bc4aa04d2883f9", oauth_token="4ba900b2cb3a6a67c13d0b089874649504d28c069", oauth_signature_method="HMAC-SHA1", oauth_signature="UKJXUjT4ZpEDeWFDVl7%2BUiqOids%3D", oauth_timestamp="1294516337", oauth_nonce="72D5BE27-D4DF-4C93-942F-96DCBCAB3509", oauth_version="1.0"
Connection: keep-alive
Cookie: PHPSESSID=676e088f8f13d7a1bb61d2437ee0b2a6
Host: localhost:8888
User-Agent: DearStranger/1.0 CFNetwork/485.12.7 Darwin/10.6.0
Answer from the provider :
X-Powered-By: PHP/5.3.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/plain
OAuth Verification Failed: Verification of signature failed (signature base string was "GET&http%3A%2F%2Flocalhost%3A8888%2FDearStranger%2Fwebservices%2Foauth%2Faccess_token.php&oauth_consumer_key%3D55af183bbbc2c386de3d0cb82a8bc4aa04d2883f9%26oauth_nonce%3D72D5BE27-D4DF-4C93-942F-96DCBCAB3509%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1294516337%26oauth_token%3D4ba900b2cb3a6a67c13d0b089874649504d28c069%26oauth_verifier%3D1234%26oauth_version%3D1.0"). with Array
(
[0] => dd918316d0190cf48d6bd6028ecbd9fc
[1] => ec0390f4ce6bbbe6a5f13a651f8b95ff
[2] => request
)
I am using OAuthConsumer on the iPhone side (http://code.google.com/p/oauthconsumer). Is there anything that this framework is doing wrong to make me get these errors ?
Thanks for your answers!
Martin
I finally found out that I wasn't using the OAuthConsumer framework for iPhone the right way. I was trying to use it the same way I should use it with the Twitter API but my server exposure doesn't have the same specifications as Twitter's.