public static function getAccessToken(
        ContextInterface $context,
        array $scopes = null,
        array $options = []
    ): AccessToken
	{
		$formParams = [
			'grant_type' => 'client_credentials',
			'client_id' => $context->getClientId(),
			'client_secret' => $context->getClientSecret(),
		];

		if ($scopes !== null) {
			$formParams['scope'] = implode(',', $scopes);
		}

        $client = SumUp::getClient($options);

		$response = $client->request(
			'POST',
			self::OAUTH_TOKEN,
			[
				'form_params' => $formParams,
			]);

		$code = $response->getStatusCode();
		if ($code !== 200) {
			$message = " Request code: $code \n Message: " . $response->getReasonPhrase();
			throw new BadRequestException($message);
		}

		$body = json_decode($response->getBody()->getContents(), true);
		$token_params = [
			$body['access_token'],
			$body['token_type'],
			$body['expires_in'],
		];

		if (isset($body['scope'])) {
			$token_params[] = $body['scope'];
		}

		return new AccessToken(...$token_params);
	}