Skip to content

Commit 28cdb3b

Browse files
committed
Merge pull request #46 from auth0/2.x.x-dev
2.x.x dev
2 parents 4b75397 + 0dc6a4d commit 28cdb3b

File tree

10 files changed

+28
-20
lines changed

10 files changed

+28
-20
lines changed

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ Check our docs page to get a complete guide on how to install it in an existing
1111
1212
## News
1313

14-
The version 1.x of the PHP SDK now works with the Auth API v2 which adds lots of new [features and changes](https://auth0.com/docs/apiv2Changes).
14+
- The version 2.x of the PHP SDK was updated to work with Guzzle 6.1. For compatibility fith Guzzle 5, you should use 1.x branch.
15+
- The version 1.x of the PHP SDK now works with the Auth API v2 which adds lots of new [features and changes](https://auth0.com/docs/apiv2Changes).
1516

1617
### Backward compatibility breaks
1718

19+
2.x
20+
- Session storage now returns null (and null is expected by the sdk) if there is no info stored (this change was made since false is a valid value to be stored in session).
21+
- Guzzle 6.1 required
22+
23+
1.x
1824
- Now, all the SDK is under the namespace `\Auth0\SDK`
1925
- The exceptions were moved to the namespace `\Auth0\SDK\Exceptions`
2026
- The method `Auth0::getUserInfo` is deprecated and soon to be removed. We encourage to use `Auth0::getUser` to enforce the adoption of the API v2
@@ -55,6 +61,11 @@ $ composer install
5561
$ php -S localhost:3000
5662
```
5763

64+
## Migration guide from 1.x
65+
66+
1. If you use Guzzle (or some other dependency does), you will need to update it to work with Guzzle 6.1.
67+
2.
68+
5869
## Migration guide from 0.6.6
5970

6071
1. First is important to read the [API v2 changes document](https://auth0.com/docs/apiv2Changes) to catch up the latest changes to the API.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=5.4.0",
14-
"guzzlehttp/guzzle": "~5.0",
14+
"guzzlehttp/guzzle": "^6.1",
1515
"ext-json": "*",
1616
"adoy/oauth2": "~1.3",
1717
"firebase/php-jwt" : "~2.2"

examples/basic-api/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"description": "Basic sample for securing an API",
44
"require": {
55
"bramus/router": "dev-master",
6-
"adoy/oauth2": "dev-master",
76
"vlucas/phpdotenv": "1.1.1",
8-
"auth0/auth0-php": "~1.0"
7+
"auth0/auth0-php": "~2.0"
98
},
109
"autoload": {
1110
"psr-4": {

examples/basic-oauth/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"name": "auth0/basic-webapp-sample",
33
"description": "Basic sample for securing a WebApp with Auth0",
44
"require": {
5-
"adoy/oauth2": "dev-master",
65
"vlucas/phpdotenv": "1.1.1",
7-
"auth0/auth0-php": "~1.0"
6+
"auth0/auth0-php": "~2.0"
87
},
98
"license": "MIT",
109
"authors": [

examples/basic-webapp/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"name": "auth0/basic-webapp-sample",
33
"description": "Basic sample for securing a WebApp with Auth0",
44
"require": {
5-
"adoy/oauth2": "dev-master",
65
"vlucas/phpdotenv": "1.1.1",
7-
"auth0/auth0-php": "~1.0"
6+
"auth0/auth0-php": "~2.0"
87
},
98
"license": "MIT",
109
"authors": [

examples/link-users/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"name": "auth0/basic-webapp-sample",
33
"description": "Basic sample for securing a WebApp with Auth0",
44
"require": {
5-
"adoy/oauth2": "dev-master",
65
"vlucas/phpdotenv": "1.1.1",
7-
"auth0/auth0-php": "~1.0"
6+
"auth0/auth0-php": "~2.0"
87
},
98
"license": "MIT",
109
"authors": [

src/API/RequestBuilder.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ public function call() {
8989
$method = $this->method;
9090

9191
try {
92-
93-
$response = $client->$method($this->getUrl(), array(
92+
93+
$response = $client->request($this->method, $this->getUrl(), [
9494
'headers' => $this->headers,
95-
'body' => $this->body
96-
));
95+
'body' => $this->body,
96+
]);
97+
$body = (string) $response->getBody();
9798

98-
return $response->json(array('object' => false));
99+
return json_decode($body, true);
99100

100101
} catch (RequestException $e) {
101102
throw $e;

src/Auth0.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private function exchangeCode() {
273273
*/
274274
public function getUser() {
275275
// Ensure we have the user info
276-
if ($this->user === false) {
276+
if ($this->user === null) {
277277
$this->exchangeCode();
278278
}
279279
if (!is_array($this->user)) {
@@ -352,7 +352,7 @@ public function setAccessToken($access_token) {
352352
* @return string
353353
*/
354354
final public function getAccessToken() {
355-
if ($this->access_token === false) {
355+
if ($this->access_token === null) {
356356
$this->exchangeCode();
357357
}
358358
return $this->access_token;
@@ -381,7 +381,7 @@ public function setIdToken($id_token) {
381381
* @return string
382382
*/
383383
final public function getIdToken() {
384-
if ($this->id_token === false) {
384+
if ($this->id_token === null) {
385385
$this->exchangeCode();
386386
}
387387
return $this->id_token;

src/Store/EmptyStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class EmptyStore
2323
public function set($key, $value) {
2424
}
2525

26-
public function get($key, $default=false) {
26+
public function get($key, $default=null) {
2727
return $default;
2828
}
2929

src/Store/SessionStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function set($key, $value) {
6565
*
6666
* @return mixed
6767
*/
68-
public function get($key, $default=false) {
68+
public function get($key, $default=null) {
6969
$key_name = $this->getSessionKeyName($key);
7070

7171
if (isset($_SESSION[$key_name])) {

0 commit comments

Comments
 (0)