Skip to content

Commit

Permalink
Add explicit config for OAuthScopes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorris committed Jan 10, 2021
1 parent 5ec175e commit c6bf9a2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public class OAuthConfigObject
/// </summary>
public string ScopeSeparator { get; set; } = " ";

/// <summary>
/// String array of initially selected oauth scopes, default is empty array
/// </summary>
public IEnumerable<string> Scopes { get; set; } = new string[] { };

/// <summary>
/// Additional query parameters added to authorizationUrl and tokenUrl
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ public static void OAuthScopeSeparator(this SwaggerUIOptions options, string val
options.OAuthConfigObject.ScopeSeparator = value;
}

/// <summary>
/// String array of initially selected oauth scopes, default is empty array
/// </summary>
public static void OAuthScopes(this SwaggerUIOptions options, params string[] scopes)
{
options.OAuthConfigObject.Scopes = scopes;
}

/// <summary>
/// Additional query parameters added to authorizationUrl and tokenUrl
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions test/WebSites/OAuth2Integration/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
c.OAuthClientSecret("test-secret");
c.OAuthAppName("test-app");
c.OAuthScopeSeparator(" ");
c.OAuthScopes("readAccess");
c.OAuthUsePkce();
});
});
Expand Down

0 comments on commit c6bf9a2

Please sign in to comment.