diff --git a/src/Provider/Buffer.php b/src/Provider/Buffer.php index 749a7e5..53f81c2 100644 --- a/src/Provider/Buffer.php +++ b/src/Provider/Buffer.php @@ -4,11 +4,14 @@ use League\OAuth2\Client\Provider\AbstractProvider; use League\OAuth2\Client\Token\AccessToken; +use League\OAuth2\Client\Tool\BearerAuthorizationTrait; use Psr\Http\Message\ResponseInterface; use Tgallice\OAuth2\Client\Provider\Exception\BufferProviderException; class Buffer extends AbstractProvider { + use BearerAuthorizationTrait; + /** * Buffer app base url * @@ -51,7 +54,7 @@ public function getBaseAccessTokenUrl(array $params) */ public function getResourceOwnerDetailsUrl(AccessToken $token) { - return $this->getApiUrl() . '/user.json?access_token=' . $token; + return $this->getApiUrl() . '/user.json'; } /** @@ -72,16 +75,6 @@ protected function getDefaultScopes() return []; } - /** - * @inheritdoc - */ - protected function getAuthorizationHeaders($token = null) - { - return [ - 'Authorization' => 'Bearer '. (string) $token, - ]; - } - /** * @inheritdoc */ diff --git a/tests/Provider/BufferTest.php b/tests/Provider/BufferTest.php index 8baa478..e150c92 100644 --- a/tests/Provider/BufferTest.php +++ b/tests/Provider/BufferTest.php @@ -48,8 +48,8 @@ public function testGetBaseAccessTokenUrl() public function testGetUrlUserDetails() { - $token = $this->getAccessToken('token'); - $this->assertEquals($this->provider->getApiUrl() . '/user.json?access_token=token', $this->provider->getResourceOwnerDetailsUrl($token)); + $token = $this->getAccessToken(); + $this->assertEquals($this->provider->getApiUrl() . '/user.json', $this->provider->getResourceOwnerDetailsUrl($token)); } public function testAuthorizationUrl() @@ -97,10 +97,8 @@ public function testGetAccessToken() } /** - * - * @expectedException Tgallice\OAuth2\Client\Provider\Exception\BufferProviderException - * - **/ + * @expectedException \Tgallice\OAuth2\Client\Provider\Exception\BufferProviderException + */ public function testExceptionThrownWhenErrorObjectReceived() { $response = $this->prophesize(ResponseInterface::class); @@ -117,12 +115,10 @@ public function testExceptionThrownWhenErrorObjectReceived() } /** - * @param null $tokenValue - * * @return AccessToken */ - private function getAccessToken($tokenValue = 'token') + private function getAccessToken() { - return new AccessToken(['access_token' => $tokenValue]); + return $this->prophesize(AccessToken::class)->reveal(); } }