yii\authclient\OAuth2::authenticateUser PHP Method

authenticateUser() public method

Authenticates user directly by 'username/password' pair, using 'password' grant type.
See also: https://tools.ietf.org/html/rfc6749#section-4.3
public authenticateUser ( string $username, string $password, array $params = [] ) : OAuthToken
$username string user name.
$password string user password.
$params array additional request params.
return OAuthToken access token.
    public function authenticateUser($username, $password, $params = [])
    {
        $defaultParams = ['client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'grant_type' => 'password', 'username' => $username, 'password' => $password];
        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;
    }