views:

45

answers:

2
+1  Q: 

twitter api issue

I'm integrating "Sign in with twitter account" function at my site.

So, I'm sending request to https ://twitter.com/oauth/request_token, getting token, making redirect to https ://twitter.com/oauth/authenticate?oauth_token=%oauth_token%

Then I recieving call back with oauth_token and oauth_verifier

This goes fine.

But than I need to call https ://api.twitter.com/1/account/verify_credentials.json to get authorizated client details

I'm sending:

GET https ://api.twitter.com/1/account/verify_credentials.json
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: q=0.8,en-us;q=0.5,en;q=0.3
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
X-Auth-Service-Provider: https ://api.twitter.com/1/account/verify_credentials.json
X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/", oauth_signature="acYFjEgUrTcyb4FMBoJF8MlwZGw%3D", oauth_timestamp="1286899670", oauth_consumer_key="%CONSUMER_KEY%", oauth_nonce="268310006", oauth_token="%oauth_token%", oauth_version="1.0", oauth_signature_method="HMAC-SHA1"

%oauth_token% - token got when twitter redirects me back the cleint
%CONSUMER_KEY% - my twitter account's consumer key

And getting back

HTTP/1.1 401 Unauthorized
Cache-Control: no-cache, max-age=300
Connection: close
Date: Tue, 12 Oct 2010 16:07:45 GMT
Server: hi
Vary: Accept-Encoding
WWW-Authenticate: Basic realm="Twitter API"

{"error":"Could not authenticate you.","request":"/1/account/verify_credentials.json"}

Can anyone plz advice me what's wrong here?

Thanks!

+1  A: 

After you receive the callback you have to make request to oauth/access_token to exchange the temporary request_token for a permanent access_token tied to the user. Once you receive the access_token you can perform the account/verify_credentials request.

http://dev.twitter.com/doc/post/oauth/access_token

abraham