How do i do the following with AuthenticationHeaderValue class?
So i basically wanna auth to github api with the basic authentication the string i'm inputing is actually
user:token
, but it won't work either, here is what i tried so far.
Client.Env["GITCREDS"]
actually returns the string.36 Replies
i always get 403 because for some reason i'm not able to auth, i want to remark that with insomnia these creds work
@Memw Have you tried breaking it down into steps and see what fails rather than embedding 3 method calls and an indexer?
yeah i logged Convert.ToBase64String(thing) before and it gave a weird string, i'm guessing comming from Encoding.ASCII.GetBytes()
@Memw And when you compared that value from the one shows encoded in the tool you took the screenshot from?
What do you mean by comparing? it is different that's all i know
Well you don't see keen on sharing any details so good luck!
i do
but what details do you want me to share
i didn't understand the question correctly, i'm not native english, so sorry for that
Alright. Since you shouldn't share a password, try with username
abc
and password def1%&
and give the values of when extracted from the setting and when encoded. I'll compare to what I have on my side.With this input
The output is
YWJjOmRlZjElJg==
@YawnderSame value as I have...
i'm actually doing this
requestClient being an HttpClient
Are you certain your
Client.Env["GITCREDS"]
returns the proper value?i logged it and yeah i'm pretty sure it does
Humn...
i can't share the full thing but yeah it does log the thing
and the thing is always
as if there were no credentials or something
Could that be it?
Wait, 403 isn't that actually
I'm using username and token
403 means the authentication is working fine, but authorization isn't.
and with insomnia http client it just gives me 200
For the same endpoint?
yup
maybe the way is not user:token? and other thing?
or github doesn't want base64? but with raw string doesn't let me either
so i'm kinda lost on that
No idea. If it works with insomnia, you could inspect using Fiddler and see what is different.
Oh.
User Agent
But why does the same credentials work for the same endpoint using another client?
Because insomnia maybe sends the user agent, i'm not sure what does it send but i'm very sure it does send the user agent
Oh! Weird that it's not stated obviously in the doc since it's atypical.
imma see if all of this user agent thingy works
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required
It's just not in the "Other Authentication" page.
it was that
damn
i just
Good then!
thanks a lot
and sorry for the missunderstanding before
Don't worry. I have a short temper when I'm tired. I should go to bed 😉