diff --git a/README.md b/README.md index d598c5db..d732f575 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,16 @@ Check our docs page to get a complete guide on how to install it in an existing ## News -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). +- 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. +- 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). ### Backward compatibility breaks +2.x +- 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). +- Guzzle 6.1 required + +1.x - Now, all the SDK is under the namespace `\Auth0\SDK` - The exceptions were moved to the namespace `\Auth0\SDK\Exceptions` - 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 $ php -S localhost:3000 ``` +## Migration guide from 1.x + +1. If you use Guzzle (or some other dependency does), you will need to update it to work with Guzzle 6.1. +2. + ## Migration guide from 0.6.6 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. diff --git a/composer.json b/composer.json index 52c87fdf..fb5f8eed 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.4.0", - "guzzlehttp/guzzle": "~5.0", + "guzzlehttp/guzzle": "^6.1", "ext-json": "*", "adoy/oauth2": "~1.3", "firebase/php-jwt" : "~2.2" diff --git a/examples/basic-api/composer.json b/examples/basic-api/composer.json index c5380cd7..4f11bd43 100644 --- a/examples/basic-api/composer.json +++ b/examples/basic-api/composer.json @@ -3,9 +3,8 @@ "description": "Basic sample for securing an API", "require": { "bramus/router": "dev-master", - "adoy/oauth2": "dev-master", "vlucas/phpdotenv": "1.1.1", - "auth0/auth0-php": "~1.0" + "auth0/auth0-php": "~2.0" }, "autoload": { "psr-4": { diff --git a/examples/basic-oauth/composer.json b/examples/basic-oauth/composer.json index e5a46898..fa522c81 100644 --- a/examples/basic-oauth/composer.json +++ b/examples/basic-oauth/composer.json @@ -2,9 +2,8 @@ "name": "auth0/basic-webapp-sample", "description": "Basic sample for securing a WebApp with Auth0", "require": { - "adoy/oauth2": "dev-master", "vlucas/phpdotenv": "1.1.1", - "auth0/auth0-php": "~1.0" + "auth0/auth0-php": "~2.0" }, "license": "MIT", "authors": [ diff --git a/examples/basic-webapp/composer.json b/examples/basic-webapp/composer.json index 078dbd38..30b22fa3 100644 --- a/examples/basic-webapp/composer.json +++ b/examples/basic-webapp/composer.json @@ -2,9 +2,8 @@ "name": "auth0/basic-webapp-sample", "description": "Basic sample for securing a WebApp with Auth0", "require": { - "adoy/oauth2": "dev-master", "vlucas/phpdotenv": "1.1.1", - "auth0/auth0-php": "~1.0" + "auth0/auth0-php": "~2.0" }, "license": "MIT", "authors": [ diff --git a/examples/link-users/composer.json b/examples/link-users/composer.json index e5a46898..fa522c81 100644 --- a/examples/link-users/composer.json +++ b/examples/link-users/composer.json @@ -2,9 +2,8 @@ "name": "auth0/basic-webapp-sample", "description": "Basic sample for securing a WebApp with Auth0", "require": { - "adoy/oauth2": "dev-master", "vlucas/phpdotenv": "1.1.1", - "auth0/auth0-php": "~1.0" + "auth0/auth0-php": "~2.0" }, "license": "MIT", "authors": [ diff --git a/src/API/RequestBuilder.php b/src/API/RequestBuilder.php index 9015401f..ccd77dce 100644 --- a/src/API/RequestBuilder.php +++ b/src/API/RequestBuilder.php @@ -89,13 +89,14 @@ public function call() { $method = $this->method; try { - - $response = $client->$method($this->getUrl(), array( + + $response = $client->request($this->method, $this->getUrl(), [ 'headers' => $this->headers, - 'body' => $this->body - )); + 'body' => $this->body, + ]); + $body = (string) $response->getBody(); - return $response->json(array('object' => false)); + return json_decode($body, true); } catch (RequestException $e) { throw $e; diff --git a/src/Auth0.php b/src/Auth0.php index 57a209c5..d0561572 100644 --- a/src/Auth0.php +++ b/src/Auth0.php @@ -273,7 +273,7 @@ private function exchangeCode() { */ public function getUser() { // Ensure we have the user info - if ($this->user === false) { + if ($this->user === null) { $this->exchangeCode(); } if (!is_array($this->user)) { @@ -352,7 +352,7 @@ public function setAccessToken($access_token) { * @return string */ final public function getAccessToken() { - if ($this->access_token === false) { + if ($this->access_token === null) { $this->exchangeCode(); } return $this->access_token; @@ -381,7 +381,7 @@ public function setIdToken($id_token) { * @return string */ final public function getIdToken() { - if ($this->id_token === false) { + if ($this->id_token === null) { $this->exchangeCode(); } return $this->id_token; diff --git a/src/Store/EmptyStore.php b/src/Store/EmptyStore.php index c52552b4..c23e9300 100644 --- a/src/Store/EmptyStore.php +++ b/src/Store/EmptyStore.php @@ -23,7 +23,7 @@ class EmptyStore public function set($key, $value) { } - public function get($key, $default=false) { + public function get($key, $default=null) { return $default; } diff --git a/src/Store/SessionStore.php b/src/Store/SessionStore.php index e7d24c4a..a9c7018b 100644 --- a/src/Store/SessionStore.php +++ b/src/Store/SessionStore.php @@ -65,7 +65,7 @@ public function set($key, $value) { * * @return mixed */ - public function get($key, $default=false) { + public function get($key, $default=null) { $key_name = $this->getSessionKeyName($key); if (isset($_SESSION[$key_name])) {