Skip to content

Commit

Permalink
Fixes bug with serialized access-token. The strange think is that som…
Browse files Browse the repository at this point in the history
…etimes a AccessToken class instance is returned from the config and sometimes only a encoded json string. The bug is reported in the main project larabros#42

Adds the .idea  (PHPStorm settings)  folder to the gitignore
  • Loading branch information
Nicolas Traeder committed Aug 1, 2016
1 parent b05a3f3 commit 33b0972
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
composer.lock
vendor
.env
.idea
9 changes: 8 additions & 1 deletion src/Http/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Larabros\Elogram\Http\Middleware;

use GuzzleHttp\Psr7\Uri;
use League\OAuth2\Client\Token\AccessToken;
use Psr\Http\Message\RequestInterface;

/**
Expand Down Expand Up @@ -30,10 +31,16 @@ public function __invoke(RequestInterface $request, array $options)
return $next($request, $options);
}

$accessToken = $this->config->get('access_token');

if (!($accessToken instanceof AccessToken)) {
$accessToken = new AccessToken(json_decode($accessToken , true));
}

$uri = Uri::withQueryValue(
$request->getUri(),
'access_token',
$this->config->get('access_token')->getToken()
$accessToken->getToken()
);

return parent::__invoke(
Expand Down

3 comments on commit 33b0972

@mige
Copy link

@mige mige commented on 33b0972 Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This commit save my live. Please, make pull request to main repo.

@lucatamtam
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please merge this pull request

@baboot
Copy link

@baboot baboot commented on 33b0972 Nov 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please merge this pull request !!! Pleaase

Please sign in to comment.