Skip to content

Commit 8ba3bb2

Browse files
committed
Fixes #11 - incorrect OAuth docs
1 parent 30896c6 commit 8ba3bb2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ $oauth = new Herbert\Envato\Auth\OAuth([
9292
]);
9393

9494
// Get the token (returns null if unavailable)
95-
$token = $oauth->token;
95+
$token = $oauth->auth;
9696

9797
// Redirect the user if they're not authorized yet
9898
if (!$token) {
@@ -128,7 +128,7 @@ if (isset($_SESSION['oauth_session'])) {
128128

129129
// No saved session, so let's start a new one
130130
else {
131-
if ($oauth->token) {
131+
if ($oauth->auth) {
132132
// Save the OAuth session
133133
$_SESSION['oauth_session'] = $oauth->session;
134134
}
@@ -140,7 +140,7 @@ else {
140140
}
141141

142142
// Create the client
143-
$client = new Herbert\EnvatoClient($oauth->token);
143+
$client = new Herbert\EnvatoClient($oauth->auth);
144144
```
145145

146146
- The `$oauth->session` member will contain a JSON string with data for the current authorization.

src/Envato/Auth/OAuth.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ public function __get($property) {
176176
if ($property == 'auth') {
177177
// Only if we've just returned from authorization
178178
if (isset($_GET['code'])) {
179-
return ($this->generatedToken) ?: $this->generateToken(trim($_GET['code']));
179+
if (!$this->generatedToken) {
180+
$this->generateToken(trim($_GET['code']));
181+
}
180182
}
183+
184+
return $this->generatedToken;
181185
}
182186

183187
// Handle session requests

0 commit comments

Comments
 (0)