How do you log in to the website without a browser!

So
Writing a C# application. I want to be able to click a link, ask the user for their username and password, and then log into GITLab to get the Private token for api calls.

This is not rocket surgery here, but for some reason, I can’t seem to have a simple: here is my authentication, now give me the damn token I need for the api.

I’ve tried getting from “/profile/account”. I then have to find this hidden “authenticity_token” from the sign in form. I then format a post to the “/users/auth/ldapmain/callback” which returns a “success” but then nothing else works. I can’t “get” the profile/account page, because that simply redirects back to the stupid sign-in. Based upon the previous “post” i was authenticated so what do I have to include in the request to get 1 simple piece of information.

Effectively I am doing the same thing (discovered through the developer mode of browser) that firefox & IE do when you click the submit button. but when I do it via the .Net HttpClient, I get “bad request”.

(people wonder why I despise web development, it’s because of this. Is it POST, is it GET, do i put information it as parameters, or are they content, yadda, yadda, yadda. 27,000 possible entry points and not a single map to explain which one GitLab uses.
Client server is sooooo much simpler (and just as secure if not more so).

Pardon my frustration but I’ve been WASTING hours on trying to figure out a simple, call and response effect.
Username, Password, now give me my private_token. Period.
How can I achieve this without using a browser, but through direct program calls.

Thanks
Jaeden “Sifo Dyas” al’Raec Ruiner

Hi @JaedenRuiner, if you are not using 2FA on your instance, you can POST to the /sessions endpoint and specify your credentials to retrieve your private_token amongst other data.

That is good to know, however it appears that after version 8.11 that functionality has been deprecated. I found the actual problem with my login process was that I was uses a StringContent instead of a ByteArrayContent. The moment I fed my input string through a UTF8 Encoder into an array of bytes for the request content, it suddenly worked perfectly.

Go figure. :slight_smile:

Thanks
J"SD"a’RR