diff --git a/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala b/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala index b474304f8b..8aa3b56980 100644 --- a/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala +++ b/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala @@ -20,4 +20,4 @@ case class OAuthFlows( authorizationCode: Option[OAuthFlow] = None ) -case class OAuthFlow(authorizationUrl: String, tokenUrl: String, refreshUrl: Option[String], scopes: ListMap[String, String]) +case class OAuthFlow(authorizationUrl: String, tokenUrl: Option[String], refreshUrl: Option[String], scopes: ListMap[String, String]) diff --git a/core/src/main/scala/sttp/tapir/EndpointIO.scala b/core/src/main/scala/sttp/tapir/EndpointIO.scala index ad04aca172..26859792fb 100644 --- a/core/src/main/scala/sttp/tapir/EndpointIO.scala +++ b/core/src/main/scala/sttp/tapir/EndpointIO.scala @@ -202,9 +202,9 @@ object EndpointInput { } case class Oauth2[T]( authorizationUrl: String, - tokenUrl: String, + tokenUrl: Option[String], scopes: ListMap[String, String], - refreshUrl: Option[String] = None, + refreshUrl: Option[String], input: EndpointInput.Single[T], challenge: WWWAuthenticate, securitySchemeName: Option[String] diff --git a/core/src/main/scala/sttp/tapir/TapirAuth.scala b/core/src/main/scala/sttp/tapir/TapirAuth.scala index ec935997cd..369c756ece 100644 --- a/core/src/main/scala/sttp/tapir/TapirAuth.scala +++ b/core/src/main/scala/sttp/tapir/TapirAuth.scala @@ -33,8 +33,8 @@ object TapirAuth { object oauth2 { def authorizationCode( authorizationUrl: String, - tokenUrl: String, scopes: ListMap[String, String], + tokenUrl: Option[String] = None, refreshUrl: Option[String] = None, challenge: WWWAuthenticate = WWWAuthenticate.bearer() ): Auth.Oauth2[String] = diff --git a/docs/openapi-docs/src/test/resources/expected_oauth2.yml b/docs/openapi-docs/src/test/resources/expected_oauth2.yml index eea4ca4c11..2f32562374 100644 --- a/docs/openapi-docs/src/test/resources/expected_oauth2.yml +++ b/docs/openapi-docs/src/test/resources/expected_oauth2.yml @@ -66,7 +66,6 @@ components: flows: authorizationCode: authorizationUrl: https://example.com/auth - tokenUrl: https://example.com/token scopes: client: scope for clients - admin: administration scope \ No newline at end of file + admin: administration scope diff --git a/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlTest.scala b/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlTest.scala index bc4a12fb2b..643fecc808 100644 --- a/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlTest.scala +++ b/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlTest.scala @@ -183,7 +183,6 @@ class VerifyYamlTest extends AnyFunSuite with Matchers { auth.oauth2 .authorizationCode( "https://example.com/auth", - "https://example.com/token", ListMap("client" -> "scope for clients", "admin" -> "administration scope") ) diff --git a/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala b/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala index 04a8611282..d59f6c24ae 100644 --- a/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala +++ b/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala @@ -41,9 +41,9 @@ object OAuth2GithubHttp4sServer extends App { case class AccessDetails(token: String) val authorizationUrl = "https://github.com/login/oauth/authorize" - val accessTokenUrl = "https://github.com/login/oauth/access_token" + val accessTokenUrl = Some("https://github.com/login/oauth/access_token") - val authOAuth2 = auth.oauth2.authorizationCode(authorizationUrl, accessTokenUrl, ListMap.empty) + val authOAuth2 = auth.oauth2.authorizationCode(authorizationUrl, ListMap.empty, accessTokenUrl) // endpoint declarations val login: Endpoint[Unit, Unit, String, Any] =