public function authenticate(string $username, string $password, ?string $scope = '*'): Response
    {
        $body = $this->mergeApiBody(
            \array_filter(\compact('username', 'password', 'scope'))
        );

        return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
                    ->validateWith(function ($statusCode, $response) {
                        if ($statusCode !== 200) {
                            throw new RuntimeException('Unable to generate access token!');
                        }

                        $this->client->setAccessToken($response->toArray()['access_token']);
                    });
    }
public function authenticate(string $username, string $password, ?string $scope = '*'): Response
    {
        $body = $this->mergeApiBody(
            \array_filter(\compact('username', 'password', 'scope'))
        );

        return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
                    ->validateWith(function ($statusCode, $response) {
                        if ($statusCode !== 200) {
                            throw new RuntimeException('Unable to generate access token!');
                        }

                        $this->client->setAccessToken($response->toArray()['access_token']);
                    });
    }
public function authenticate ( string $ username , string $ password , ? string $ scope = '*' ) : Response { $ body = $ this -> mergeApiBody ( \ array_filter ( \ compact ( 'username' , 'password' , 'scope' ) ) ) ; return $ this -> send ( 'POST' , 'oauth/token' , $ this -> getApiHeaders ( ) , $ body ) -> validateWith ( function ( $ statusCode , $ response ) { if ( $ statusCode !== 200 ) { throw new RuntimeException ( 'Unable to generate access token!' ) ; } $ this -> client -> setAccessToken ( $ response -> toArray ( ) [ 'access_token' ] ) ; } ) ; }
Create access token.

@param string $username
@param string $password
@param string|null $scope

@return \Laravie\Codex\Contracts\Response
Create access token .