Http post request to login with username and password programmatically?

Hello,

I am attempting to find the correct url and parameters to login to extrahop from a java program, using only my username and password.

I have looked at the .js files and packet data in wireshark to try and find the correct url to login using these parameters, but it is very well hidden inside of the javascript.

So far, the only thing I have found is the following: extrahop.com/admin/auth/login/

Initializing this post request and adding my username and password was unsuccessful.

Any help would be greatly appreciated.

Thank You

CloseableHttpClient client = HttpClientBuilder.create()
        .setRedirectStrategy(new LaxRedirectStrategy())
        .build()
BasicCookieStore cookieStore = new BasicCookieStore()
Executor executor = Executor.newInstance(client).use(cookieStore)

Response response =
        executor.execute(Request.Post("https://extrahop.com/admin/auth/login")
                .bodyForm(Form.form()
                .add("username", "myusername")
                .add("password", "mypassword")
                .add("target", "")
                .build()))
System.out.println()

Here is the corresponding javascript where the request is built

export const postLogin = async (
    user: string,
    pass: string,
    token: string,
): Promise<AuthResponse | UnauthResponse | undefined> => {
    const form = new URLSearchParams();
    form.set('username', user);
    form.set('password', pass);

    return (
        await fetch(LOGIN_PATH, {
            method: 'POST',
            body: form.toString(),
            headers: {
                accept: 'application/json',
                'X-CSRFToken': token,
                'Content-type': 'application/x-www-form-urlencoded',
            },
        })
    ).json();
};

Hi @rsantiago - May I suggest using the REST API? You simply include your API key in the request header for authentication, like the below example.

curl -i -X GET --header "Accept: application/json"  --header "Authorization: ExtraHop 
apikey=2bc07e55971d4c9a88d0bb4d29ecbb29" "https://<hostname-or-IP-of-your-ExtraHop- 
system>/api/v1/extrahop"

If you’re on 360, there is a good example here: Reveal(x) 360 REST API Guide

If the REST API doesn’t cover your request, could you please let me know more about your use case and what you’re trying to accomplish? In general, you’ll want to login direct to admin using this uri: https://{your_appliance}/admin/login/