open source / oauth4s / runtimes
Runtimes
| Module | Import | Effect |
|---|---|---|
oauth4s-cats |
oauth4s.runtime.cats.CatsInstances.given |
any F with cats.effect.Async |
oauth4s-zio |
oauth4s.runtime.zio.ZioInstances.given |
zio.Task |
oauth4s-kyo |
oauth4s.runtime.kyo.KyoInstances.given |
KIO[A] = A < (Async & Abort[Throwable]) |
oauth4s-rapid |
oauth4s.runtime.rapid.RapidInstances.given |
rapid.Task |
oauth4s-core |
nothing | scala.util.Try, on the calling thread |
Code that is written against Effect[F] does not know which one it runs on:
scala
final class Billing[F[*]](client: OAuthClient[F])(using F: Effect[F]):
private val tokens = TokenSource.clientCredentials(client, Scope.of("invoices:read"))
def invoices(fetch: AccessToken => F[List[String]]): F[List[String]] =
F.flatMap(tokens.accessToken)(fetch)scala
import cats.effect.IO
import oauth4s.http.HttpClient
import oauth4s.http.jdk.JdkHttpClient
import oauth4s.runtime.cats.CatsInstances.given
given HttpClient[IO] = JdkHttpClient[IO]()
def billing(config: OAuthClientConfig): Billing[IO] = Billing(OAuthClient[IO](config))scala
import zio.Task
import oauth4s.http.HttpClient
import oauth4s.http.jdk.JdkHttpClient
import oauth4s.runtime.zio.ZioInstances.given
given HttpClient[Task] = JdkHttpClient[Task]()
def billing(config: OAuthClientConfig): Billing[Task] = Billing(OAuthClient[Task](config))Without an effect system the effect is Try, and its instance needs no import:
scala
import scala.util.Try
import oauth4s.http.HttpClient
import oauth4s.http.jdk.JdkHttpClient
given HttpClient[Try] = JdkHttpClient[Try]()
def token(config: OAuthClientConfig): Try[TokenResponse] =
OAuthClient[Try](config).clientCredentials() // the request has happened by the time this returnsEffect[F] is pure, delay, map, flatMap, raiseError, handleErrorWith and sleep, plus realTime and
blocking, which have defaults that each runtime replaces with its own clock and its own blocking pool. A test clock
in cats-effect or ZIO therefore moves token expiry with it.
built from README.md at v0.1.1
edit this page on GitHub