PHP Classes

Access token retrieve

Recommend this page to a friend!

      PHP oAuth2 lightweight wrapper  >  All threads  >  Access token retrieve  >  (Un) Subscribe thread alerts  
Subject:Access token retrieve
Summary:How can access the access token out of the library
Author:Stavros Zavrakas
Date:2014-07-01 11:23:56

  1. Access token retrieve   Reply   Report abuse  
Picture of Stavros Zavrakas Stavros Zavrakas - 2014-07-01 11:23:56

I start using your library and it was quite easy to deploy together with laravel 4. I have a question, that possibly is a bug but I am not really sure and I would like to ask you about that. You have a public variable on the class that is named $accessToken. As I see in the module you never use it, or initialize. I suppose that this variable is used to have access to the access token out of the module. I modify a little bit the module initialize this variable in the Initialize function adding this line:
$this->accessToken = null; (line 78)

The second change that I did is in the public function getUserProfile() and assign back the acccess token to the class variable like that:
$this->accessToken = $atoken; (line 402)

I could do it in the function getAccessToken but I as I see you normalize the values for different social networks in the getUserProfile that's why I assign the accessToken there.

Like that I can have access to the accessToken that I need like that:
$oauth = new socialmedia_oauth_connect();


$oauth->client_id = "";
$oauth->client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
$oauth->redirect_uri ="";


$code = ($_REQUEST["code"]) ? ($_REQUEST["code"]) : "";

if(empty($code)) {
$oauth->code = $code;
$getData = json_decode($oauth->getUserProfile());

// line that makes the difference
/* redirect here */

Can you tell me if I am wrong in the concept? Is it possible to add this change to your module?