diff --git a/README.md b/README.md index ddf47ff..6954780 100755 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ $oauth = new Herbert\Envato\Auth\OAuth([ ]); // Get the token (returns null if unavailable) -$token = $oauth->token; +$token = $oauth->auth; // Redirect the user if they're not authorized yet if (!$token) { @@ -128,7 +128,7 @@ if (isset($_SESSION['oauth_session'])) { // No saved session, so let's start a new one else { - if ($oauth->token) { + if ($oauth->auth) { // Save the OAuth session $_SESSION['oauth_session'] = $oauth->session; } @@ -140,7 +140,7 @@ else { } // Create the client -$client = new Herbert\EnvatoClient($oauth->token); +$client = new Herbert\EnvatoClient($oauth->auth); ``` - The `$oauth->session` member will contain a JSON string with data for the current authorization. diff --git a/src/Envato/Auth/OAuth.php b/src/Envato/Auth/OAuth.php index 7e0fa92..aacfc8b 100644 --- a/src/Envato/Auth/OAuth.php +++ b/src/Envato/Auth/OAuth.php @@ -176,8 +176,12 @@ public function __get($property) { if ($property == 'auth') { // Only if we've just returned from authorization if (isset($_GET['code'])) { - return ($this->generatedToken) ?: $this->generateToken(trim($_GET['code'])); + if (!$this->generatedToken) { + $this->generateToken(trim($_GET['code'])); + } } + + return $this->generatedToken; } // Handle session requests