firebase-client-scala


License

License

Categories

Categories

Scala Languages CLI User Interface
GroupId

GroupId

io.github.mkotsur
ArtifactId

ArtifactId

firebase-client-scala_2.12
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

firebase-client-scala
firebase-client-scala
Project URL

Project URL

https://github.com/mkotsur/firebase-client-scala
Project Organization

Project Organization

io.github.mkotsur
Source Code Management

Source Code Management

https://github.com/mkotsur/firebase-client-scala

Download firebase-client-scala_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.mkotsur/firebase-client-scala_2.12/ -->
<dependency>
    <groupId>io.github.mkotsur</groupId>
    <artifactId>firebase-client-scala_2.12</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.mkotsur/firebase-client-scala_2.12/
implementation 'io.github.mkotsur:firebase-client-scala_2.12:0.0.4'
// https://jarcasting.com/artifacts/io.github.mkotsur/firebase-client-scala_2.12/
implementation ("io.github.mkotsur:firebase-client-scala_2.12:0.0.4")
'io.github.mkotsur:firebase-client-scala_2.12:jar:0.0.4'
<dependency org="io.github.mkotsur" name="firebase-client-scala_2.12" rev="0.0.4">
  <artifact name="firebase-client-scala_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.mkotsur', module='firebase-client-scala_2.12', version='0.0.4')
)
libraryDependencies += "io.github.mkotsur" % "firebase-client-scala_2.12" % "0.0.4"
[io.github.mkotsur/firebase-client-scala_2.12 "0.0.4"]

Dependencies

compile (9)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.1
io.circe : circe-core_2.12 jar 0.7.0
io.circe : circe-generic_2.12 jar 0.7.0
io.circe : circe-parser_2.12 jar 0.7.0
com.github.kxbmap : configs_2.12 jar 0.4.4
org.scalaj : scalaj-http_2.12 jar 2.3.0
org.bouncycastle : bcpkix-jdk15on jar 1.55
com.google.api-client : google-api-client jar 1.22.0
com.google.identitytoolkit : gitkitclient jar 1.2.7

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.0

Project Modules

There are no modules declared in this project.

Codacy Badge Build status Maven Central

⚠️ This project is not maintained anymore ⚠️

This is a Scala REST client for Firebase, which is based on Circe and is intended for services that don't require realtimeness of Firebase and just need to ger read/write access to the database in a convenient way.

Features:

  • Fetching access token based on admin credentials aka service accounts;
  • CRUD operations;
  • Listing / adding / removing users [TBD].

Documentation

Authentication

One thing to always remember: in order to use this lib, you need a service account, and your app will always be accessing data on behalf of that service account. Kind of "admin access", so it's responsibility of your app to make sure that all the changes are legitimate.

Example

Database operations:

import java.nio.file.{Files, Paths}
import io.github.mkotsur.firebase.auth.AdminCredentials
import io.github.mkotsur.firebase.rest.FirebaseClient
import io.circe.generic.auto._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits._

val jsonKey: Array[Byte] = Files.readAllBytes(
    Paths.get(getClass.getResource("/rest-client-scala-test-b1940c24c184.json").toURI)
)

val client = new FirebaseClient("rest-client-scala-test")
implicit val token = FirebaseClient.getToken(AdminCredentials(jsonKey)).get

// Reading a primitive
val ageFuture: Future[Option[Int]] = client.get[Int]("users/001/age")

// Reading an object as a case class
case class User(age: Int)
val userFuture: Future[Option[User]] = client.get[User]("users/001")


// more examples in ./src/test/scala/io/github/mkotsur/firebase/rest/FirebaseClientTest.scala

Caveats

  • The library adds BouncyCastle provider at runtime. Not necessarily a bad thing, but something to be aware of;
  • There is a transitive dependency on Guava via gitkitclient;
  • Behavior of FirebaseUsers.createUser mimics gitkit behavior may be somewhat counter-intuitive. Please make sure to fully understand how it works before using in your app.

Adding to your project

libraryDependencies += "io.github.mkotsur" %% "firebase-client-scala" % {latest-version}

Development

The tests are executed against a firebase instance rest-client-scala-test (configured in application-test.conf).

There should be a user: [email protected] / 123qwe.

Versions

Version
0.0.4
0.0.3