diff --git a/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/auth/GoogleOAuth2.scala b/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/auth/GoogleOAuth2.scala index 4455748c4..0e41b30c2 100644 --- a/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/auth/GoogleOAuth2.scala +++ b/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/auth/GoogleOAuth2.scala @@ -69,7 +69,7 @@ private[auth] object GoogleOAuth2 { .expiresIn(3600) .issuedNow - JwtSprayJson.encode(claim, privateKey, RS256) + JwtSprayJson(clock).encode(claim, privateKey, RS256) } final case class JwtClaimContent(scope: String) diff --git a/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/jwt/JwtSprayJson.scala b/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/jwt/JwtSprayJson.scala index d10fff1ca..dc2ede264 100644 --- a/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/jwt/JwtSprayJson.scala +++ b/google-common/src/main/scala/org/apache/pekko/stream/connectors/google/jwt/JwtSprayJson.scala @@ -39,10 +39,15 @@ private[google] trait JwtSprayJsonParser[H, C] extends JwtJsonCommon[JsObject, H } @InternalApi -private[google] object JwtSprayJson extends JwtSprayJsonParser[JwtHeader, JwtClaim] { - import DefaultJsonProtocol._ - +private[google] object JwtSprayJson { def apply(clock: Clock): JwtSprayJson = new JwtSprayJson(clock) +} + +@InternalApi +private[google] class JwtSprayJson private (defaultClock: Clock) + extends JwtSprayJsonParser[JwtHeader, JwtClaim] { + import DefaultJsonProtocol._ + implicit val clock: Clock = defaultClock override def parseHeader(header: String): JwtHeader = { val jsObj = parse(header) @@ -75,10 +80,3 @@ private[google] object JwtSprayJson extends JwtSprayJsonParser[JwtHeader, JwtCla private[this] def safeGetField[A: JsonReader](js: JsObject, name: String) = js.fields.get(name).flatMap(safeRead[A]) } - -@InternalApi -private[google] class JwtSprayJson private (override val clock: Clock) - extends JwtSprayJsonParser[JwtHeader, JwtClaim] { - override def parseHeader(header: String): JwtHeader = JwtSprayJson.parseHeader(header) - override def parseClaim(header: String): JwtClaim = JwtSprayJson.parseClaim(header) -}