Skip to content

Instantly share code, notes, and snippets.

@iwannabebot
Last active May 13, 2018 08:01
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 iwannabebot/35cc02f21da4cb52763efa298d00d04f to your computer and use it in GitHub Desktop.
Save iwannabebot/35cc02f21da4cb52763efa298d00d04f to your computer and use it in GitHub Desktop.
Add OAuth2/OpenID compatible middleware to Swagger
public void ConfigureServices(IServiceCollection services)
{
// Other settings
services
.AddSwaggerGen(c =>
{
// Other settings
c.AddSecurityDefinition("oauth2", new OAuth2Scheme
{
Type = "oauth2",
Flow = "implicit",
AuthorizationUrl = Configuration
.GetSection("Authority").Value,
Scopes = GetScopes("my_api")
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment