Skip to main content

Authentication

authentication diagram

Using JSON Web Tokens

You can either use the warehouseLogin mutation or the integratorLogin mutation (depending on wether you're logging as an IntegratorUser or a WarehouseWorker)

Both mutations will return an accessToken, which is a valid JWT.

In order to authenticate calls to the API, you need to pass the JWT as a HTTP header like this:

{
"authorization": "Bearer {your-jwt}"
}

Note that you can inspect any JWT via jwt.io and see which data is carried within it.

Integrator setup

Role

If you want to create WarehouseWorkers you need at the very least a Role with permissions like this:

mutation {
createRole(
name: "my-integrator-role"
permissions: [{ table: WAREHOUSE_WORKER, mode: WRITE }]
) {
id
name
}
}

User

Then you also need a user account that can log in

mutation {
createIntegratorUser(
email: "jdoe+integrator@example.com"
password: "$ecret"
roleId: "my-integrator-role-id"
integratorId: "my-integrator-id"
) {
id
email
}
}

Login

Log into your user account to obtain a JSON Web Token (JWT)

mutation {
integratorLogin(
email: "jdoe+integrator@example.com"
password: "$ecret"
integratorId: "my-integrator-id"
) {
accessToken
}
}

Create a WarehouseWorker

You can now create your first WarehouseWorker.

We're going to call him the "Warehouse admin" since we will give him permissions to invite his colleagues

mutation {
createRole(
name: "acme-labs-admin"
permissions: [
{ table: WAREHOUSE_WORKER, mode: WRITE }
{ table: ARTICLE, mode: WRITE }
]
) {
id
name
}
}
mutation {
createWarehouseWorker(
username: "warehouse-admin"
password: "$ecret"
roleId: "acme-labs-admin-id"
warehouseId: "my-warehouse-id"
) {
id
username
}
}

We've now created an admin that can invite other WarehouseWorkers into his Client account!

Client setup

As a Client organization, you have a WarehouseWorker user that can log in via the warehouseLogin mutation

mutation {
warehouseLogin(
username: "warehouse-admin-1"
password: "$ecret"
warehouseId: "my-warehouse"
) {
accessToken
}
}

You can then perform actions into the Warehouse depending on your permissions, such as:

Creating a temp worker

mutation {
createRole(
name: "temp-worker-role"
permissions: [{ table: ARTICLE, mode: READ }]
) {
id
name
}
}
mutation {
createWarehouseWorker(
username: "temp-worker-1"
password: "$ecret"
roleId: "temp-worker-role-id"
warehouseId: "my-warehouse-id"
) {
id
username
}
}

Creating an Article

mutation {
createArticle(
input: {
name: "my-article"
accountId: 1
companyId: 1
status: 1
code: "testcode"
length: 24.2
width: 2.3
height: 1.4
baseUnitWeight: 1.02
boxWeight: 1.2
boxQuantity: 3
baseUnitPicking: true
boxPicking: false
cubingType: 1
permanentProduct: false
}
) {
id
name
created
}
}