public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verifier)
{
if ($temporaryIdentifier !== $temporaryCredentials->getIdentifier()) {
throw new \InvalidArgumentException('Temporary identifier passed back by server does not match that of stored temporary credentials.
Potential man-in-the-middle.');
}
$uri = $this->urlTokenCredentials();
$bodyParameters = ['oauth_verifier' => $verifier];
$client = $this->createHttpClient();
$headers = $this->getHeaders($temporaryCredentials, 'POST', $uri, $bodyParameters);
try {
if (get_class($client) == 'GuzzleHttp\\Client') {
$response = $client->post($uri, ['headers' => $headers, 'form_params' => $bodyParameters]);
} else {
$response = $client->post($uri, $headers, $bodyParameters)->send();
}
} catch (BadResponseException $e) {
return $this->handleTokenCredentialsBadResponse($e);
}
return ['tokenCredentials' => $this->createTokenCredentials($response->getBody()), 'credentialsResponseBody' => $response->getBody()];
}