Skip to content

Instantly share code, notes, and snippets.

@nigel-sampson
Created January 22, 2014 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nigel-sampson/8566230 to your computer and use it in GitHub Desktop.
Save nigel-sampson/8566230 to your computer and use it in GitHub Desktop.
Octokit OAuth Token Ruest
var gitHubClient = new GitHubClient(new ProductHeaderValue("Test App", "0.0.0.1"))
{
Credentials = Credentials.Anonymous
};
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"client_id", ClientId },
{"client_secret", ClientSecret },
{"code", responseParameters["code"] },
{"state", state }
});
var response = await gitHubClient.Connection.PostAsync<AccessToken>(new Uri("https://github.com/login/oauth/access_token", UriKind.Absolute), content, "application/json", "application/x-www-form-urlencoded");
return new Credentials(response.BodyAsObject.Token);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment