Before you start
- Node.js
- Go
- .NET
- Python
- Java
- CLI
- curl
- You have obtained FGA API credentials and set
FGA_API_URL,FGA_STORE_ID,FGA_API_TOKEN_ISSUER,FGA_API_AUDIENCE,FGA_CLIENT_ID, andFGA_CLIENT_SECRET. - You have installed the SDK.
- You have configured the authorization model and updated the relationship tuples.
- You have loaded
FGA_API_URL,FGA_STORE_ID,FGA_API_TOKEN_ISSUER,FGA_API_AUDIENCE,FGA_CLIENT_IDandFGA_CLIENT_SECRETas environment variables.
Step by step
Assume that you want to check whether useranne has relationship reader with object document:Z
01. Configure the Auth0 FGA API client
Before calling the check API, you will need to configure the API client.- Node.js
- Go
- .NET
- Python
- Java
- CLI
- curl
02. Calling Check API
To check whether useruser:anne has relationship reader with object document:Z
The result’s allowed field will return true if the relationship exists and false if the relationship does not exist.
03. Calling Batch Check API
If you want to check multiple user-object-relationship combinations in a single request, you can use the Batch Check API endpoint. Batching authorization checks together in a single request significantly reduces overall network latency. The BatchCheck endpoint requires acorrelation_id parameter for each check. The correlation_id is used to “correlate” the check responses with the checks sent in the request, since tuple_keys and contextual_tuples are not returned in the response on purpose to reduce data transfer to improve network latency. A correlation_id can be composed of any string of alphanumeric characters or dashes between 1-36 characters in length.
This means you can use:
- simple iterating integers
1,2,3,etc - UUID
e5fe049b-f252-40b3-b795-fe485d588279 - ULID
01JBMD9YG0XH3B4GVA8A9D2PSN - or some other unique string
correlation_id within a request must be unique.
If you are using one of our SDKs:
- the
correlation_idis inserted for you by default and automatically correlates theallowedresponse with the propertuple_key - if you pass in more checks than the server supports in a single call (
50), the SDK will automatically split and batch theBatchCheckrequests for you, how it does this can be configured using themaxBatchSizeandmaxParallelRequestsoptions in the SDK.
user:anne has multiple relationships writer and reader with object document:Z
The result will include an allowed field for each authorization check that will return true if the relationship exists and false if the relationship does not exist.