Creating and validating JWT JSON web tokens

This article goes through the process of creating and validating JWT’s (JSON web tokens) using Scala. Our implementation uses the awesome io.jsonwebtoken library, and can be added to a sbt project like this: libraryDependencies ++= Seq("io.jsonwebtoken" % "jjwt" % "0.9.1") Creating a token We are going to use Scala’s apply/unapply functions for this implementation. This will allow us to use matchers for checking JWT’s. import java.time.Instant import java.util.{Date, UUID} import io.

Make a request to a remote service

This article shows how to make remote requests to services using Scala and the Play-Framework. It documents some recommended features that can improve the reliability of the request. Setup Make sure you add the following dependency to build.sbt libraryDependencies += ws GET request GET request to a remote service import scala.concurrent.Future import play.api.http.Status._ import import play.api.libs.json.{JsSuccess, Json} case class UnexpectedResponseStatus(message: String) extends Exception(message) case class InvalidServiceResponse(message: String) extends Exception(message) class SomeClass @Inject()( ws: WSClient ) { def getFromRemoteService(url: String): Future[Option[MyClass]] = { ws.