Newly generated Twitter App Access Tokens are not valid, and Refreshing / Regenerating the token does not work



I created a Twitter App earlier this week. It generated the Consumer Key / Secret and the Access Token / Secret.

I created a Twitter test app built around the current version of Abraham Williams’ Twitter OAuth library. Everything appears to be working, except that the Access Token is not valid.

When I put in the Access Token into the url****, I get the response that ‘The request token for this page is invalid. It may have already been used, or expired because it is too old.’ I do not understand how a brand new Access Token can be expired or invalid.

When I attempt to Regenerate the Access Token and Secret, shows me the same token and the same secret.

How do I get a valid Access Token and Secret for a new app for Twitter?


How do I get valid Access Tokens for my app and test user?

#3 is only used when you don’t have a user’s access_token yet. Since you have the access token from the app page you can skip that step and just start using the credentials for the user that created the app.


Thank you for your response.

I understand. The issue is that the Access Token and Secret generated by are not valid, and Refreshing does not generate new ones.


How do you know it’s invalid? How are you trying to use it?


I attempted using the generated Access Token to post a Tweet, to verify_credentials, and to get status?user_timeline. My PHP always got the response error 215. I ultimately tested the generated Access Token with oauth/authenticate, and the page informed me that the Access Token was invalid.
After deleting the app and creating a brand new Twitter App with a brand new set of Keys and Access Tokens, I was still getting the same response (error 215, invalid token).


Show a code sample of how you are using the tokens because I would expect the ones generated by Twitter to never be invalid.


Thank you for taking the time to assist with this. Your help is greatly appreciated.


if (!defined(‘CONSUMER_KEY’))
define(‘CONSUMER_KEY’, ‘****’);

if (!defined(‘CONSUMER_SECRET’))
define(‘CONSUMER_SECRET’, ‘****’);

if (!defined(‘OAUTH_TOKEN’))
define(‘OAUTH_TOKEN’, ‘-’);

if (!defined(‘OAUTH_SECRET’))
define(‘OAUTH_SECRET’, ‘****’);

$connection = new Abraham\TwitterOAuth\TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);

$content = $connection->get(‘account/verify_credentials’);

$post = “upload test”;
$status = $connection->post(‘statuses/update’, array(‘status’ => $post));

echo json_encode($status);

Adding print statements to parts of the OAuth library is how I figured out that the OAuth response is error 215 - Bad Authentication Data.

The content and status objects are both NULL after the code is executed.


Is there anything wrong with my block of code?

If the Access Token is valid, what other causes would be creating the error 215 response I am seeing?