跳到主要内容

OAuth Flows 对象

允许配置支持的 OAuth Flows。

固定字段

字段名类型描述
implicitOAuth Flow 对象OAuth Implicit flow 的配置
passwordOAuth Flow 对象OAuth Resource Owner Password flow 的配置
clientCredentialsOAuth Flow 对象OAuth Client Credentials flow 的配置。在 OpenAPI 2.0 中曾被称作 application
authorizationCodeOAuth Flow 对象OAuth Authorization Code flow 的配置。在 OpenAPI 2.0 中曾被称作 accessCode

这个对象可能会被规范扩展扩展。

OAuth Flow 对象

支持的 OAuth Flow 的配置详情。

固定字段

字段名类型Applies To描述
authorizationUrlstringoauth2 ("implicit", "authorizationCode")必选。用于此流程的 authorization URL。必须是 URL 形式。
tokenUrlstringoauth2 ("password", "clientCredentials", "authorizationCode")必选。用于此流程的 token URL。必须是 URL 形式。
refreshUrlstringoauth2用于获取 refresh tokens 的 URL,必须是 URL 形式。
scopesMap[string, string]oauth2必选。可用于 OAuth2 security scheme 的 scope。scope 名称与其简短描述的映射。

这个对象可能会被规范扩展扩展。

OAuth Flow 对象示例

{
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "https://example.com/api/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
},
"authorizationCode": {
"authorizationUrl": "https://example.com/api/oauth/dialog",
"tokenUrl": "https://example.com/api/oauth/token",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
}
type: oauth2
flows:
implicit:
authorizationUrl: https://example.com/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
authorizationCode:
authorizationUrl: https://example.com/api/oauth/dialog
tokenUrl: https://example.com/api/oauth/token
scopes:
write:pets: modify pets in your account
read:pets: read your pets