memw
memw
CC#
Created by memw on 1/23/2023 in #help
✅ Consistent way to Authorize with HttpClient?
So i'm trying to send a request to the discord API with <HttpClient> and i tried a couple ways to authorize this being one:
<HttpClient>.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"Bot {Config.Values!.DiscordToken}");
<HttpClient>.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"Bot {Config.Values!.DiscordToken}");
But this one doesn't work and it always will send me an unauthorized response 401 Before anything, yes i tried the token, i Console.Writeline'd the token and i made the same request with insomnia client and it works there.
6 replies
CC#
Created by memw on 12/20/2022 in #help
❔ Reflections and generics
So i have a type instance list and i'm iterating trough all the fields that the propertyType.Name.Contains("ExtensionConfig"), that type has a method which i need to invoke foreach field and i'm iterating trough the fields So basically the problem comes when i do (field as PropertyInfo).GetValue(type) shows invalid cast exception, and i can't cast because the target type has a generic type which in every field is different
96 replies
CC#
Created by memw on 10/11/2022 in #help
How do i do the following with AuthenticationHeaderValue class?
50 replies
CC#
Created by memw on 9/23/2022 in #help
How do delegates work
I have a little problem understanding what type i need to pass a delegate to AddEventHandler because i'm getting the function from reflection and MethodInfo.CreateDelegate tells me i need to pass a type which i don't understand what would that type be for or what derives from a delegate exactly
25 replies