Skip to main content

Connect your app

Integrate into your own application

To integrate Permit.io into your own application, you can use the Permit SDK (or work with the API directly).

Let's say that you have a web app that uses the Permit SDK to check for permissions. In the app, each user that signs in should have a unique identifier - such as a user-id / email / Auth0Id / CognitoId / etc.

Your user object probably looks something like this (an example from Auth0):

Example user object

{
"user": {
"id": "abc123livrjeoigv",
"tenant": "my-tenant",
"username": "user1",
"password": "xxxxxxx",
"email": "user1@foo.com",
"first_name": "John",
"last_name": "Doe",
"emailVerified": true
}
}

Sync user

This SDK function is used to sync a user's data with the Permit.io PDP upon the users creation.

note

Once the user has been synced with Permit, you should not use this API call anymore to update the user's Role (use assignRole instead).

UserKey userObj = new UserKey(user.id, user.first_name, user.last_name, user.email);
permit.Api.SyncUser(userObj);

Assign user

To update a user's role after a user has been synced/created, you can use the following function:

assignedRole = await permit.Api.AssignRole(user.customId, Role.id, Tenant.externalId);

List roles

To get the available roles, you can use the following function:

Role[] roles = await permit.Api.GetRoles();

Manage resources

To sync your resources and actions you can use our web application.

Or you can use the SyncResources SDK function.

List tenants

To get the available tenants, you can use the following api call