/**
  * @param AuthorizationResponse $authResponse
  * @throws StateMismatchException
  */
 public function handleAuthorizationResponse(AuthorizationResponse $authResponse)
 {
     if (!$this->stateStore->validateResponse($authResponse)) {
         throw new StateMismatchException('State does not match');
     }
     $tokenRequest = new TokenRequest($this->clientConfig, $this->serverConfig, $this->httpClient, $authResponse);
     $tokenResponse = $tokenRequest->send();
     $this->tokenStore->updateFromTokenResponse($tokenResponse);
 }
 public function testSend()
 {
     $token = 'token_ABC123';
     $this->given->iAmReadyToRespondToATokenRequest($token, $this->scope, $this->mockHandler);
     $tokenRequest = new TokenRequest($this->clientConfig, $this->serverConfig, $this->httpClient, $this->authorization);
     $tokenResponse = $tokenRequest->send();
     $this->shouldHaveMadeATokenRequest();
     $this->assertInstanceOf(TokenResponse::class, $tokenResponse);
     $this->assertEquals($token, $tokenResponse->getToken());
 }
 /**
  * @param AuthorizationResponse $authResponse
  */
 public function handleAuthorizationResponse(AuthorizationResponse $authResponse)
 {
     $tokenRequest = new TokenRequest($this->clientConfig, $this->serverConfig, $this->httpClient, $authResponse);
     $tokenResponse = $tokenRequest->send();
     $this->tokenStore->updateFromTokenResponse($tokenResponse);
 }