Алексей Ерохин

Алексей Ерохин

Был в сети 15 апреля 2025, 15:28
Заказы не принимаю
Судя по всему дело в этом
To request access tokens, you need to provide the following POST parameters to the token URI, using your client ID and secret with HTTP Basic Authorization
нужно передать авторизацию в заголовках
а battle.net принимает client_secret и client_id из заголовков запроса
curl_setopt($ch,CURLOPT_HTTPHEADER,'Authorization: Basic ' . base64_encode($this->client_id .  ':' . $this->client_secret);
github.com/bezumkin/modx-hybridauth/blob/master/core/components/hybridauth/model/hybridauth/lib/thirdparty/OAuth/OAuth2Client.php#L34
github.com/bezumkin/modx-hybridauth/blob/master/core/components/hybridauth/model/hybridauth/lib/thirdparty/OAuth/OAuth2Client.php#L211

По идее надо сделать так в BattleNet.php:

function initialize()
	{
		parent::initialize();

		// Provider api end-points
		$this->api->authorize_url  = "https://eu.battle.net/oauth/authorize";
		$this->api->token_url      = "https://eu.battle.net/oauth/token";
               $this->api->curl_header      = array('Authorization: Basic ' . base64_encode($this->client_id .  ':' . $this->client_secret);
		$this->state = bin2hex(openssl_random_pseudo_bytes(16));
		if (!empty($this->config['fields']))
			$this->fields = $this->config['fields'];
	}