Could not authenticate with OAuth



I’m using the tmhOAuth library for my website to link accounts, update statusses, etc. Linking accounts works fine, no errors. But when I’m trying to post a status update, I’m getting this error:

{“error”:“Could not authenticate with OAuth.”,“request”:"/1/account/verify_credentials.json"}

Using the following code:


 * Verify the user token and secret works. If successful we will be given the
 * details of the user. If not an error explaining why will be returned.
 * Although this example uses your user token/secret, you can use
 * the user token/secret of any user who has authorised your application.
 * This example differs from others in that it will reattempt a request if
 * the timestamp is detected to be off from the Twitter servers.
 * Instructions:
 * 1) If you don't have one already, create a Twitter application on
 * 2) From the application details page copy the consumer key and consumer
 *      secret into the place in this code marked with (YOUR_CONSUMER_KEY
 * 4) Visit the 'My Access Token' screen linked to from your application
 *      details page
 * 5) Copy the user token and user secret into the place in this code marked
 *      with (A_USER_TOKEN and A_USER_SECRET)
 * 6) Visit this page using your web browser.
 * @author themattharris

require '../tmhOAuth.php';
require '../tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
  'consumer_key'    => '###########',     // Got this from Consumer key
  'consumer_secret' => '##################',     // Got this from Consumer secret
  'user_token'      => '###-############',     // Got this from Access token
  'user_secret'     => '#################',     // Got this from Access token secret

// for the demo set the timestamp to yesterday
$tmhOAuth->config['force_timestamp'] = true;
$tmhOAuth->config['timestamp'] = strtotime('yesterday');

$code = tmhUtilities::auto_fix_time_request($tmhOAuth, 'GET', $tmhOAuth->url('1/account/verify_credentials'));

if ($code == 200) {
  if ($tmhOAuth->auto_fixed_time)
    echo 'Had to auto adjust the time. Please check the date and time is correct on your device/server';

} else {


Access level: R&W+DM

I think there is a problem with the user_token and the user_secret. I already searched the interwebs for solutions, I also found this exact problem, but none of the solutions work.

Please help me.


PS. I also saw some threads with formatted code. How do I do that?


I am having the similar problem. Using tmhOAuth library and I receiving the same error. Have not found a solution on the interwebs either…



I am having issues while trying to post a tweet using an App from Nokia S60 device. Following is the issue:-

  1. I want to login into Twitter from Nokia Web browser on N8. Previously it is working fine but form last 4 days, I am getting problem on login screen. I am unable to click signin because of Javascript/jquery thing.
  2. On computer browser if i click on user_email_id then on “blur” and on “keypress” event is fired but if i do the same on mobile browser there is no action performed there.
  3. I think twitter have issue with “Onblur” and “OnKeypress” event of javascript/jquery on mobile web browser.
  4. I tried to login from default browser on Nokia device, effect is browser crashes because of issue with javascript.

This is urgent please help.


anyone solved this? I’m having this issue 13 weeks later.


Im using another library now. @abraham his lib. Contact him or me if you want details or a how-to or whatever


I am also getting the same issue but I am using EpiOAuth Lib…Can anyone please help me out

Thanks in Advance


Today I wanted to connect my Word Press blog site with my twitter account but have no idea where to find the twitter consume key or consumer secret .

Everywhere I look becomes more complex. I am not computer literate and this makes it more frustrating.
Now when I go to my wordpress site it is asking for the above, yet on Twitter it says it is okay

Can someone help please. Don’t send links just show me where these keys are found.
Please email using the address on my account.

Thank you


I am having the same problem but I am using @abraham library. Below is my code. I just want to verify my user and be able to see home_timeline. I am able to pull information from public_timeline.

<?php session_start(); require_once('lib/twitteroauth/twitteroauth.php'); require_once('lib/config.php');

function getSessionToken(){
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);

/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$_SESSION['oauth_access_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_access_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
  case 200:
	/* Build authorize URL and redirect user to Twitter. */
	$url = $connection->getAuthorizeURL($token);
	header('Location: ' . $url); 
	/* Show notification if something went wrong. */
	echo 'Could not connect to Twitter. Refresh the page or try again later.';


/* If access tokens are not available redirect to connect page. /
if ((!isset($_SESSION[‘oauth_access_token’])) || ($_SESSION[‘oauth_access_token’])==’’)
Get user access tokens out of the session. */
$access_token = $_SESSION[‘oauth_access_token’];

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION[‘oauth_access_token’], $_SESSION[‘oauth_access_token_secret’]);

/* If method is set change API call made. Test is called by default. */
$content = $connection->get(‘account/rate_limit_status’);
echo “Current API hits remaining: {$content->remaining_hits}.

/* Get logged in user to help with tests. */
$user = $connection->get(‘account/verify_credentials’);



go to twitter developers site there is a link called create ur application .
enter the details and accept terms and conditions and set create access token it displays key and secret


I’d say that one of the biggest problems with this code is that every line that does anything related to authorization is commented out. Have you tried configuring the library according to the documentation?


Hi guys,

I’m facing the same issue. I am using @abraham library, which is giving me the following error:

There is no request token for this page. That’s the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

Any idea as to what maybe going wrong?


@abraham’s library isn’t giving you that error, twitter is. Your problem is that you are not passing in an oauth token to the authorize url ( The correct URL would be something like I’m using tmhOAuth library. This oauth token is obtained from extract_params on the response from