Skip to content

Instantly share code, notes, and snippets.

@nemesv
Created April 28, 2016 19:15
Show Gist options
  • Save nemesv/3ac06ff08dc454dd3f7240fac936051b to your computer and use it in GitHub Desktop.
Save nemesv/3ac06ff08dc454dd3f7240fac936051b to your computer and use it in GitHub Desktop.
private OAuthOptions GitHubOptions =>
new OAuthOptions
{
AuthenticationScheme = "GitHub",
DisplayName = "GitHub",
ClientId = Configuration["GitHub:ClientId"],
ClientSecret = Configuration["GitHub:ClientSecret"],
CallbackPath = new PathString("/signin-github"),
AuthorizationEndpoint = "https://github.com/login/oauth/authorize",
TokenEndpoint = "https://github.com/login/oauth/access_token",
UserInformationEndpoint = "https://api.github.com/user",
ClaimsIssuer = "OAuth2-Github",
Scope = { "user", "repo" },
SaveTokensAsClaims = true,
// Retrieving user information is unique to each provider.
Events = new OAuthEvents
{
OnCreatingTicket = async context => { await CreatingGitHubAuthTicket(context); }
}
};
private OAuthOptions GitHubOptions
{
get
{
var gitHubOptions = new OAuthOptions
{
AuthenticationScheme = "GitHub",
DisplayName = "GitHub",
ClientId = Configuration["GitHub:ClientId"],
ClientSecret = Configuration["GitHub:ClientSecret"],
CallbackPath = new PathString("/signin-github"),
AuthorizationEndpoint = "https://github.com/login/oauth/authorize",
TokenEndpoint = "https://github.com/login/oauth/access_token",
UserInformationEndpoint = "https://api.github.com/user",
ClaimsIssuer = "OAuth2-Github",
SaveTokensAsClaims = true,
// Retrieving user information is unique to each provider.
Events = new OAuthEvents
{
OnCreatingTicket = async context => { await CreatingGitHubAuthTicket(context); }
}
};
gitHubOptions.Scope.Add("user");
gitHubOptions.Scope.Add("repo");
return gitHubOptions;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment