yii\authclient\OAuth2::authenticateClient PHP Method

authenticateClient() public method

Authenticate OAuth client directly at the provider without third party (user) involved, using 'client_credentials' grant type.
See also: http://tools.ietf.org/html/rfc6749#section-4.4
public authenticateClient ( array $params = [] ) : OAuthToken
$params array additional request params.
return OAuthToken access token.
    public function authenticateClient($params = [])
    {
        $defaultParams = ['client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'grant_type' => 'client_credentials'];
        if (!empty($this->scope)) {
            $defaultParams['scope'] = $this->scope;
        }
        $request = $this->createRequest()->setMethod('POST')->setUrl($this->tokenUrl)->setData(array_merge($defaultParams, $params));
        $response = $this->sendRequest($request);
        $token = $this->createToken(['params' => $response]);
        $this->setAccessToken($token);
        return $token;
    }