Why am I getting the "Could not authenticate you" message from Twitter's API?
-
I'm creating a website and I want to allow users to sign in with Twitter. I followed a tutorial and everything seemed to work. But when I allowed authentication from Twitter I got the above error. Here's the exact message I get: stdClass Object ( [request] => /1/account/verify_credentials.json?oauth_consumer_key=*********&oauth_nonce=*********************&oauth_signature=****************************&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1302636413&oauth_token=&oauth_version=1.0 [error] => Could not authenticate you. ) Any idea why I could be getting this? If you would like me to post the exact code I'm using on every page related to this please inform me. Here's the code after the user accepts to authorize my site: <?php require("twitteroauth/twitteroauth.php"); session_start(); function redirect(){ header('Location: twitterauthorize.php'); } if(!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])){ $twitteroauth= new TwitterOauth('**************************', '************************************', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); $access_token=$twitteroauth->getAccessToken($_GET['oauth_verifier']); $_SESSION['access_token']= $access_token; $user_info=$twitteroauth->get('account/verify_credentials'); print_r($user_info); } else { redirect(); } ?>
-
Answer:
There are many reasons OAuth authentication can fail, but I think in this specific case, you're not including the access token in your request -- the API response here indicates that Twitter cannot find a user context to perform your request. The user context would be told to Twitter through the oauth_token=xyz parameter, which appears to be an empty value here. Your oauth_token field should be populated with the oauth_token value you received when exchanging the request token for the access token. Your signature generation step in this context should be signed with a composite string made up of your consumer secret and the access token secret (oauth_token_secret). If it's possible, I recommend using HTTP header-based Authentication instead of attaching your OAuth values to the query string of the URL -- it dramatically separates concerns and makes debugging easier.
Taylor Singletary at Quora Visit the source
Other answers
There are two answers for this error. Either you haven't given the oauth_token correctly or the parameters used in the function call are not in proper format as per Oauth. You might wanna check the errors in parameters supplied for a function to OAuth.
Tousif Baig
Related Q & A:
- Why am I getting an "Expected Identifier" error?Best solution by Stack Overflow
- Why am i getting an ArgumentOutOfRangeException?Best solution by Stack Overflow
- Why am I getting error unwrapping Optional if it has a value?Best solution by Stack Overflow
- Why am I getting error on page?Best solution by Yahoo! Answers
- Why am I getting a Yahoo Mail Error?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.