"401 Not Authorized" in API OAuth PHP authorization

87 views
Skip to first unread message

@matheuseduardo

unread,
Mar 18, 2011, 8:01:05 AM3/18/11
to twitter-deve...@googlegroups.com
I have tested the api twitter with at least four solutions (one of them everworked before, months ago) in PHP, and getting the same error: "401 Not Authorized".

Is there any "novelty", any prior authorization to be given to theapplication?

There are others with the same problem?

Someone trying anything new in PHP and working well?

Scott Wilcox

unread,
Mar 18, 2011, 8:02:13 AM3/18/11
to twitter-deve...@googlegroups.com
Checked your tokens are correct?

@matheuseduardo

unread,
Mar 18, 2011, 8:47:55 AM3/18/11
to twitter-deve...@googlegroups.com
Yep! And try to reset keys, delete application, create other, create other in other user... and nothing worked as well!

I've downloaded some ready for test examples from github, from posts.. nothing.

Even the popular "@abraham's Twitter OAuth library for PHP" (which was just change the two keys and worked in past) did not work here! and have the same error "401 Not Authorized" in header (instead 200 Ok).

There is someone trying "something new" in PHP with Oauth, that can send me the sample files so I just enter my keys and test?

Rgds

(sorry for bad english, with the help of google translator)

Ninjamonk

unread,
Mar 18, 2011, 9:18:34 AM3/18/11
to Twitter Development Talk
I am having the same issue, code that worked yesterday is now throwing
401's - I am using .net

Ninjamonk

unread,
Mar 18, 2011, 9:27:38 AM3/18/11
to Twitter Development Talk
it seems to be back and working fine now.

@matheuseduardo

unread,
Mar 18, 2011, 9:54:18 AM3/18/11
to twitter-deve...@googlegroups.com
My problem persist and I still receiving a "Failed to validate oauth signature and token".
But in all examples is well signed with "HMAC-SHA1" as suposed to be.

I can't get the "request token" therefore I can't get the "authenticate url" (to access twitter authentication page, etc).

Someone can help?

@matheuseduardo

unread,
Mar 18, 2011, 2:28:07 PM3/18/11
to twitter-deve...@googlegroups.com

Anyone using PHP having this same problem?

Anyone with sample working code to send me?



Scott Wilcox

unread,
Mar 18, 2011, 2:29:13 PM3/18/11
to twitter-deve...@googlegroups.com
Check the time is accurate on the machine you're running the code on.

@matheuseduardo

unread,
Mar 18, 2011, 2:49:17 PM3/18/11
to twitter-deve...@googlegroups.com
seems to be ok
the function that generate the is just:

function generate_timestamp() {
   return time();
}


and in header I have the parameter: [oauth_timestamp] => 1300471769

the error received from request in twitter api is: "Failed to validate oauth signature and token" and header 401

Must be signature?

I just think it's weird because it's happening in all library and examples ready for tests..

Matt Harris

unread,
Mar 19, 2011, 2:08:56 PM3/19/11
to twitter-deve...@googlegroups.com
Hi,

The error message "Failed to validate oauth signature and token" does mean either the signature you are sending, or the consumer token is invalid. Could you share the request you are making, and response you are getting. Remember to obscure any user or consumer secrets.

Best,
@themattharris
Developer Advocate, Twitter
http://twitter.com/themattharris


--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk

@matheuseduardo

unread,
Mar 21, 2011, 1:19:26 PM3/21/11
to twitter-deve...@googlegroups.com
just a question: for request, the time need to be GMT 0?

@matheuseduardo

unread,
Mar 21, 2011, 1:34:05 PM3/21/11
to twitter-deve...@googlegroups.com
I'm doing another try.. and this time I trying with "Wootter" that is a twitter opensource "client".
Then I've downloaded and just change the keys in config.php. In Demo server is right working... but in my server, not.
I just don't know why can't get authenticate url through request that is responding with 401 header.

devjyoti patra

unread,
Mar 22, 2011, 8:14:13 AM3/22/11
to twitter-deve...@googlegroups.com
Hi,

My Streaming APi code has suddenly started to throw 401 (UNAUTHORIZED) message. It was working properly till yesterday and hence I'm sure that my credentials are okay. This is what I'm catching after sending my oAuth tokens.

Error 401
Problem accessing /1/statuses/filter.json. Reason: UNAUTHORIZED

Thanks,
Devjyoti



--
Reply all
Reply to author
Forward
0 new messages