Php - OAuth2 and App Only



Hi, I hope I am in the right forum.

Actually I make a call to the endpoint like that :

$token = base64_encode(urlencode($twitter_clientid) . ':' . urlencode($twitter_secret));
        $client = new \GuzzleHttp\Client();
        $response = $client->post('', [
            'headers' => [
                'Authorization' => 'Basic ' . $token,
                'Accept' => 'application/json'
            'form_params' => [
                'grant_type' => 'client_credentials'

        $result = json_decode($response->getBody()->getContents());
        $bearerToken = $result->access_token;
        var_dump($bearerToken); // return a token here

I can get a valid Bearer Token. Now what to do ? How do I go troughs the Single Login process (if its possible at all) ? I can’t find anything in the doc.
My goal is to retrieve user information, like nickname or the email address.

Any help/example appreciated, thanks you all.


App only authentication is for a small group of endpoints that do not require a user login or context. If you need user-specific data (e.g. a timeline) then you’ll need to go through a three-legged OAuth flow.


Hi how can i force logout from twitter i.e user log in from my application to to twitter but when i give him logout option its just clearing from my session not from twitter session. I know i can use force login but this it not the solution for me . Is ther anything like force logout from twitter also.