A set of Examples on how to call the OpenFGA Java SDK
Example 1: A bare-bones example. It creates a store, and runs a set of calls against it including creating a model, writing tuples and checking for access. This example is implemented in both Java and Kotlin.
Prerequisites:
dockermake- A Java Runtime Environment (JRE)
Steps
- Clone/Copy the example folder
- Run
maketo build the project - If you have an OpenFGA server running, you can use it, otherwise run
make run-openfgato spin up an instance (you'll need to switch to a different terminal after - don't forget to close it when done) - Run
make runto run the example- This should run a Java example by default. Where implemented, it's possible to specify an alternate JVM language too, like
make run language=kotlin.
- This should run a Java example by default. Where implemented, it's possible to specify an alternate JVM language too, like
Steps
- Build the SDK
- In the Example project file (e.g.
build.gradle), comment out the part that specifies the remote SDK, e.g.
dependencies {
implementation("dev.openfga:openfga-sdk:0.4.+")
// ...etc
}and replace it with one pointing to the local gradle project, e.g.
dependencies {
// implementation("dev.openfga:openfga-sdk:0.4.+")
implementation project(path: ':')
// ...etc
}- Run
maketo build the project - If you have an OpenFGA server running, you can use it, otherwise run
make run-openfgato spin up an instance (you'll need to switch to a different terminal after - don't forget to close it when done) - Run
make runto run the example