protected function createRequest($client, $userId, $request, array $scopes)
    {
        return (new ServerRequest)->withParsedBody(
            ['grant_type' => 'password',
            'client_id' => $client->id,
            'client_secret' => $client->secret,
            'username' => $request->get('email'),
            'password' => $request->get('password'),
            'user_id' => $userId,
            'scope' => implode(' ', $scopes)]
        );
    }