Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tokenUrl optional as Oauth implicit grant flow doesn't use it #997

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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