Skip to content

Commit

Permalink
Merge pull request #46 from auth0/2.x.x-dev
Browse files Browse the repository at this point in the history
2.x.x dev
  • Loading branch information
glena committed Nov 23, 2015
2 parents 4b75397 + 0dc6a4d commit 28cdb3b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 20 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions examples/basic-api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions examples/basic-oauth/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 1 addition & 2 deletions examples/basic-webapp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 1 addition & 2 deletions examples/link-users/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
11 changes: 6 additions & 5 deletions src/API/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Store/EmptyStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Store/SessionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down

0 comments on commit 28cdb3b

Please sign in to comment.