Service Delegation
If you are building an application or script that needs to act on behalf of multiple users you will want to setup a service account and use a concept called service delegation.
Delgation:
The act or process of entrusting (a task or responsibility) to another person
Set up a Service Account
At the moment service accounts can only be created by our team here at Unearth.
Once we create a service account, you will receive a set of credentials in the form of an access_key
and secret_access_key
which you will be able to use to authenticate.
Assuming Delegation
If you have successfully authenticated as the service you will be able to assume delegation for any of the users that have granted delegate access. This is done simply by making the following request:
Method: POST
Address: https://auth.unearthlabs.com/assume
Authorization: Bearer {YOUR_TOKEN}
Content-Type: application/json
Body:
Note: The USER_ID_OR_EMAIL
in this URN can either be id associated with the user in Unearth, or the user's email address. We consider either form to uniquely identify a user.
{"id":"urn:ue:user:{USER_ID_OR_EMAIL}"}
In response you will receive two new tokens:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlJlZnJlc2ggRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.DJ2REc5nRP_pGugENadLxFSoWb2M717D4yZ7oU5OrTY"
}
Using these tokens will cause the Unearth API to behave as though you had authenticated as that user.
Updated 11 months ago