認證是直接關係到記錄您的API,而不是實際執行中,可以這麼說。 所以,如果你使用你的swaggerConfig如下:
c.OAuth2("oauth2")
.Description("OAuth2 Implicit Grant")
.Flow("implicit")
.AuthorizationUrl("http://petstore.swagger.io/oauth/dialog")
.Scopes(scopes =>
{
scopes.Add("read:pets", "read your pets");
scopes.Add("write:pets", "modify pets in your account");
});
這將產生在招搖JSON文件中的以下securitydefinition
securityDefinitions:
petstore_auth:
type: oauth2
authorizationUrl: 'http://petstore.swagger.io/oauth/dialog'
flow: implicit
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
要回答
我怎麼能要求身份驗證用 wsfederation查看swagger ui?
只需添加全球認證的WebApiConfig.cs
文件,類似於以下(如果您正在使用的MessageHandler或過濾器)
config.Filters.Add(new WSFederationAuthentication());
查看招搖文檔直接的WebAPI相關的東西。
雖然您可能會遇到一些問題,因爲Swagger獲得了文檔客戶端。