Skip to content

Instantly share code, notes, and snippets.

View oesolberg's full-sized avatar

Odd Erik Midthaug oesolberg

View GitHub Profile
@teocomi
teocomi / oauth2-restsharp.cs
Last active March 6, 2023 10:33
OAuth2 C# RestSharp
string url = "https://myurl.com";
string client_id = "client_id";
string client_secret = "client_secret";
//request token
var restclient = new RestClient(url);
RestRequest request = new RestRequest("request/oauth") {Method = Method.POST};
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", client_id);
request.AddParameter("client_secret", client_secret);
@cairey
cairey / gist:5501024
Last active August 20, 2021 12:07
Programmatically start IIS Express from code.
public static class IISExpress
{
private static readonly List<string> sites = new List<string>();
private static readonly List<string> paths = new List<string>();
public static void StartIISExpress(string site, int port = 7329)
{
if(!sites.Contains(site.ToLower()))
sites.Add(site.ToLower());
else return;