babychristopher2023
Member
- Joined
- Aug 26, 2023
- Messages
- 14
- Programming Experience
- Beginner
what is the proper way to create a console app using .net 7 and use http client to hit an api endpoint that requires oauth?
Please read the flurl docs on their website; doing auth is essentially a one line operation:would still have same hurdles of passing in basic auth
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api");
request.Headers.Add("Authorization", "Basic sldfjasjfasklfjdsjajfjasjfasjajjf");
var content = new StringContent("", null, "text/plain");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Skip()
and Take()
methods if you need to roll your own. If you decide not to implement that caching and just do the brute force of always getting all the data from the source, then you apply the skip and take on those results. But if you implement the caching, then you apply it on your cache.