$scopes List of scopes (e.g. ['beneficiaries', 'payment']) * @param string|null $state Optional state parameter for CSRF protection */ public function getAuthUrl(array $scopes = ['beneficiaries'], ?string $state = null): string { $baseUrl = $this->environment === Environment::PRODUCTION ? 'https://id.alfabank.ru/oidc/authorize' : 'https://id-sandbox.alfabank.ru/oidc/authorize'; $params = [ 'response_type' => 'code', 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, 'scope' => implode(' ', $scopes), ]; if ($state) { $params['state'] = $state; } return $baseUrl . '?' . http_build_query($params); } /** * Step 2: Exchange the received code for Access & Refresh Tokens. */ public function exchangeCode(string $code): TokenData { return $this->connector->authWithCode($code, $this->redirectUri); } /** * Step 3: Refresh the token using a stored refresh token. */ public function refreshToken(string $refreshToken): TokenData { return $this->connector->refreshToken($refreshToken); } }