/**
  * @param array $formParams
  *
  * @return TokenInterface
  */
 public function getAccessToken(array $formParams)
 {
     try {
         $response = $this->client->request('POST', $this->tokenEndpoint, ['form_params' => $formParams]);
         $statusCode = $response->getStatusCode();
     } catch (BadResponseException $e) {
         $statusCode = $e->getResponse()->getStatusCode();
     }
     if (200 !== $statusCode) {
         throw TokenRetrieveException::invalidStatusCode($statusCode);
     }
     $json = json_decode($response->getBody(), true);
     if (null === $json || false === is_array($json)) {
         throw TokenRetrieveException::invalidResponseBody((string) $response->getBody());
     }
     return new Token($json['access_token'], $json['expires_in'], $json['token_type'], $json['scope'], $json['refresh_token']);
 }
 /**
  * @depends testClass
  */
 public function testInvalidResponseBody()
 {
     $exception = TokenRetrieveException::invalidResponseBody('abcdef');
     $this->assertInstanceOf(TokenRetrieveException::class, $exception);
     $this->assertEquals('Server returns invalid body: abcdef', $exception->getMessage());
 }