Skip to content

Commit

Permalink
Merge pull request #997 from softwaremill/bug/737
Browse files Browse the repository at this point in the history
make tokenUrl optional as Oauth implicit grant flow doesn't use it
  • Loading branch information
adamw authored Feb 8, 2021
2 parents da00a0e + e634d1f commit 0e3b58b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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])
4 changes: 2 additions & 2 deletions core/src/main/scala/sttp/tapir/EndpointIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/sttp/tapir/TapirAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
3 changes: 1 addition & 2 deletions docs/openapi-docs/src/test/resources/expected_oauth2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
admin: administration scope
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down

0 comments on commit 0e3b58b

Please sign in to comment.