{"id":13520948,"url":"https://github.com/authzed/authzed-java","last_synced_at":"2025-06-17T16:34:34.813Z","repository":{"id":43674805,"uuid":"386788697","full_name":"authzed/authzed-java","owner":"authzed","description":"Official SpiceDB client library for JVM languages","archived":false,"fork":false,"pushed_at":"2025-06-03T19:33:34.000Z","size":15311,"stargazers_count":22,"open_issues_count":8,"forks_count":10,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-13T10:16:29.547Z","etag":null,"topics":["authorization","authzed","clojure","fine-grained-access-control","fine-grained-authorization","java","java-library","permissions","sdk","zanzibar"],"latest_commit_sha":null,"homepage":"https://docs.authzed.com/reference/api","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/authzed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-16T23:31:44.000Z","updated_at":"2025-06-03T19:33:34.000Z","dependencies_parsed_at":"2024-01-18T17:42:35.765Z","dependency_job_id":"e304d07e-aea6-49c7-b6e8-c35d840ab8be","html_url":"https://github.com/authzed/authzed-java","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/authzed/authzed-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/authzed","download_url":"https://codeload.github.com/authzed/authzed-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260398874,"owners_count":23003068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","authzed","clojure","fine-grained-access-control","fine-grained-authorization","java","java-library","permissions","sdk","zanzibar"],"created_at":"2024-08-01T06:00:24.915Z","updated_at":"2025-06-17T16:34:29.798Z","avatar_url":"https://github.com/authzed.png","language":"Java","funding_links":[],"categories":["Clients"],"sub_categories":["Official Libraries"],"readme":"# Authzed Java Client\n\n[![Maven Metadata](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fcom%2Fauthzed%2Fapi%2Fauthzed%2Fmaven-metadata.xml)](https://search.maven.org/artifact/com.authzed.api/authzed)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://github.com/authzed/authzed-java/workflows/build/badge.svg)](https://github.com/authzed/authzed-java/actions)\n[![Discord Server](https://img.shields.io/discord/844600078504951838?color=7289da\u0026logo=discord \"Discord Server\")](https://discord.gg/jTysUaxXzM)\n[![Twitter](https://img.shields.io/twitter/follow/authzed?color=%23179CF0\u0026logo=twitter\u0026style=flat-square)](https://twitter.com/authzed)\n\nThis repository houses the Java client library for [SpiceDB].\n\n[SpiceDB] is a database and service that stores, computes, and validates your application's permissions.\n\nDevelopers create a schema that models their permissions requirements and use a client library, such as this one, to apply the schema to the database, insert data into the database, and query the data to efficiently check permissions in their applications.\n\nSupported client API versions:\n- [v1](https://authzed.com/docs/reference/api#authzedapiv1)\n\nYou can find more info on each API on the [SpiceDB API reference documentation].\nAdditionally, Protobuf API documentation can be found on the [Buf Registry SpiceDB API repository].\nDocumentation for the latest Java client release is available as [Javadoc].\n\nSee [CONTRIBUTING.md] for instructions on contributing and performing common tasks like building the project and running tests.\n\n[Authzed]: https://authzed.com\n[SpiceDB]: https://github.com/authzed/spicedb\n[SpiceDB API Reference documentation]: https://authzed.com/docs/reference/api\n[Buf Registry SpiceDB API repository]: https://buf.build/authzed/api/docs/main\n[CONTRIBUTING.md]: CONTRIBUTING.md\n[Javadoc]: https://authzed.github.io/authzed-java/index.html\n\n## Getting Started\n\nWe highly recommend following the **[Protecting Your First App]** guide to learn the latest best practice to integrate an application with SpiceDB.\n\nIf you're interested in examples for a specific API version, they can be found in their respective folders in the [examples directory].\n\n[Protecting Your First App]: https://authzed.com/docs/guides/first-app\n[examples directory]: /examples\n\n## Basic Usage\n\n### Installation\n\nThis project is packaged as the artifact `authzed` under the `com.authzed.api` group on [Maven Central].\nYou can find the commands for installing the jar for various JVM toolchains on the [Maven Central Artifact Page].\n\nMost commonly, if you are using [Maven] you can add the following to your pom.xml:\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.authzed.api\u003c/groupId\u003e\n        \u003cartifactId\u003eauthzed\u003c/artifactId\u003e\n        \u003cversion\u003e1.3.0\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.grpc\u003c/groupId\u003e\n        \u003cartifactId\u003egrpc-protobuf\u003c/artifactId\u003e\n        \u003cversion\u003e1.66.0\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.grpc\u003c/groupId\u003e\n        \u003cartifactId\u003egrpc-stub\u003c/artifactId\u003e\n        \u003cversion\u003e1.66.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nIf you are using [Gradle] then add the following to your `build.gradle` file:\n\n```groovy\ndependencies {\n    implementation \"com.authzed.api:authzed:v1.0.0\"\n    implementation 'io.grpc:grpc-protobuf:1.66.0'\n    implementation 'io.grpc:grpc-stub:1.66.0'\n}\n```\n\n[Maven Central]: https://maven.apache.org/repository/index.html\n[Maven Central Artifact Page]: https://search.maven.org/artifact/com.authzed.api/authzed\n[Maven]: https://maven.apache.org\n[Gradle]: https://gradle.org/\n\n### Initializing a client\n\nBecause of how [grpc-java] is designed, there is little in terms of abstraction over the gRPC APIs underpinning Authzed.\nA `ManagedChannel` will establish a connection to Authzed that can be shared with _stubs_ for each gRPC service.\nTo successfully authenticate with the API, you will have to provide a [Bearer Token] with your own API Token\nfrom the [Authzed dashboard] or your local SpiceDB instance in place of `t_your_token_here_1234567deadbeef` as \n`CallCredentials` for each stub:\n\n```java\npackage org.example;\n\nimport com.authzed.api.v1.PermissionsServiceGrpc;\nimport com.authzed.grpcutil.BearerToken;\nimport io.grpc.ManagedChannel;\nimport io.grpc.ManagedChannelBuilder;\n\npublic class PermissionServiceExample {\n    public static void main(String[] args) {\n        ManagedChannel channel = ManagedChannelBuilder\n                .forTarget(\"grpc.authzed.com:443\")\n                .useTransportSecurity()\n                .build();\n\n        BearerToken bearerToken = new BearerToken(\"t_your_token_here_1234567deadbeef\");\n        PermissionsServiceGrpc.PermissionsServiceBlockingStub permissionsService = PermissionsServiceGrpc\n                .newBlockingStub(channel)\n                .withCallCredentials(bearerToken);\n    }\n}\n```\n\nIn case of a local development instance of SpiceDB without TLS, configure your `ManagedChannel` as follows:\n\n```java\nManagedChannel channel = ManagedChannelBuilder\n    .forTarget(\"localhost:50051\")\n    .usePlaintext()\n    .build();\n```\n\n[grpc-java]: https://github.com/grpc/grpc-java\n[Bearer Token]: https://authzed.com/docs/reference/api#authentication\n[Authzed dashboard]: https://app.authzed.com/\n\n### Performing an API call\n\nRequest and Response types are located in their respective gRPC Service packages and common types can be found in the Core package.\nReferring to the [Authzed ProtoBuf Documentation] is useful for discovering these APIs.\n\nBecause of the verbosity of these types, we recommend writing your own functions/methods to create these types from your existing application's models.\n\nThe following example initializes a permission client, performs a `CheckPermission` call and prints the result\n\n[Authzed Protobuf Documentation]: https://buf.build/authzed/api/docs/main\n\n```java\npackage org.example;\n\nimport com.authzed.api.v1.*;\nimport com.authzed.grpcutil.BearerToken;\nimport io.grpc.ManagedChannel;\nimport io.grpc.ManagedChannelBuilder;\n\npublic class ClientExample {\n    public static void main(String[] args) {\n        ManagedChannel channel = ManagedChannelBuilder\n                .forTarget(\"localhost:50051\")\n                .usePlaintext()\n                .build();\n\n        BearerToken bearerToken = new BearerToken(\"t_your_token_here_1234567deadbeef\");\n        PermissionsServiceGrpc.PermissionsServiceBlockingStub permissionsService = PermissionsServiceGrpc\n                .newBlockingStub(channel)\n                .withCallCredentials(bearerToken);\n\n\n        CheckPermissionRequest request = CheckPermissionRequest.newBuilder()\n                .setConsistency(\n                        Consistency.newBuilder()\n                                .setMinimizeLatency(true)\n                                .build())\n                .setResource(\n                        ObjectReference.newBuilder()\n                                .setObjectType(\"blog/post\")\n                                .setObjectId(\"1\")\n                                .build())\n                .setSubject(\n                        SubjectReference.newBuilder()\n                                .setObject(\n                                        ObjectReference.newBuilder()\n                                                .setObjectType(\"blog/user\")\n                                                .setObjectId(\"emilia\")\n                                                .build())\n                                .build())\n                .setPermission(\"read\")\n                .build();\n\n        // Is Emilia in the set of users that can read post #1?\n        try {\n            CheckPermissionResponse response = permissionsService.checkPermission(request);\n            System.out.println(\"result: \" + response.getPermissionship().getValueDescriptor().getName());\n        } catch (Exception e) {\n            System.out.println(\"Failed to check permission: \" + e.getMessage());\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fauthzed-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauthzed%2Fauthzed-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fauthzed-java/lists"}