The Access Token API gives users and administrators a way to programmatically list, disable, create, and delete access tokens. Non-administrator users are permitted to execute requests against their own access tokens and no others. Administrator users are permitted to execute requests against their own access tokens and access tokens assigned to service accounts. To use these endpoints one must have first used the Login API to receive a session token. All requests can use either Auth header token credentials or cookie token credentials.
For Non-Admin Users
Listing all Access Tokens
This endpoint will provide a list of access tokens that exists for yourself. This will return a json list of access tokens.
# using the token as auth header curl -X GET https://<your_organization>.silect.is/api/magpie/access-token -H "Authorization: token <the session token returned from login>" # using the token as cookie curl -X GET https://<your_organization>.silect.is/api/magpie/access-token -b "token=<the session token returned from login>"
# Using the token as auth header
headers = {"Authorization": f"token {token}"}
response = requests.get(
"https://<your_organization>.silect.is/api/magpie/access-token",
headers=headers
)
# Using the token as cookie
cookies = {"token": token}
response = requests.get(
"https://<your_organization>.silect.is/api/magpie/access-token",
cookies=cookies
)
Create an Access Token
Use this endpoint to create an access token for yourself. This will return a json with the access token embedded. You will not be able to get this token again, so make sure you save it while it is available to you.
curl -X POST https://<your_organization>.silect.is/api/magpie/access-token \
-H "Authorization: token <the session token returned from login>"
# returns {"token": "new access token"}
cookies = {"token": token}
response = requests.post(
"https://<your_organization>.silect.is/api/magpie/access-token",
headers={"Content-Type": "application/json"},
cookies=cookies
)
Enable/Disable an Access Token
Use this endpoint to enable or disable an access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above. The status will be set to true for disabled and false for enabled.
# to disable a token curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/true \ -H "Authorization: token <the session token returned from login>" # to enable a token curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/false \ -H "Authorization: token <the session token returned from login>"
cookies = {"token": token}
response = requests.put(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/true",
headers={"Content-Type": "application/json"},
cookies=cookies
)
Add/Update Description for an Access Token
Use this endpoint to add/update a description to the access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above.
curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description \ -H "Authorization: token <the session token returned from login>" -d "the description you want added/updated"
cookies = {"token": token}
response = requests.put(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description",
data='the description you want added/updated'
cookies=cookies
)
Delete an Access Token
Use this endpoint to delete an access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above.
curl -X DELETE https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description \ -H "Authorization: token <the session token returned from login>"
cookies = {"token": token}
response = requests.delete(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>",
cookies=cookies
)
For Admin Users Handling Service Accounts
Only Admin users may make changes to service account access tokens.
Listing all Access Tokens for Service Accounts
This endpoint will provide a list of access tokens that exists for a service account. This will return a json list of access tokens.
# using the token as auth header curl -X GET https://<your_organization>.silect.is/api/magpie/access-token/user/<user name> -H "Authorization: token <the session token returned from login>" # using the token as cookie curl -X GET https://<your_organization>.silect.is/api/magpie/access-token/user/<user name> -b "token=<the session token returned from login>"
# Using the token as auth header
headers = {"Authorization": f"token {token}"}
response = requests.get(
"https://<your_organization>.silect.is/api/magpie/access-token/user/<user name>",
headers=headers
)
# Using the token as cookie
cookies = {"token": token}
response = requests.get(
"https://<your_organization>.silect.is/api/magpie/access-token/user/<user name>",
cookies=cookies
)
Create an Access Token for Service Accounts
Use this endpoint to create an access token for a service account. This will return a json with the access token embedded. You will not be able to get this token again, so make sure you save it while it is available to you.
curl -X POST https://<your_organization>.silect.is/api/magpie/access-token/user/<user name> \
-H "Authorization: token <the session token returned from login>"
# returns {"token": "new access token"}
cookies = {"token": token}
response = requests.post(
"https://<your_organization>.silect.is/api/magpie/access-token/user/<user name>",
headers={"Content-Type": "application/json"},
cookies=cookies
)
Enable/Disable an Access Token for Service Accounts
Use this endpoint to enable or disable an access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above. The status will be set to true for disabled and false for enabled.
# to disable a token curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/true \ -H "Authorization: token <the session token returned from login>" # to enable a token curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/false \ -H "Authorization: token <the session token returned from login>"
cookies = {"token": token}
response = requests.put(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/status/true",
headers={"Content-Type": "application/json"},
cookies=cookies
)
Add/Update Description for an Access Token for Service Accounts
Use this endpoint to add/update a description to the access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above.
curl -X PUT https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description \ -H "Authorization: token <the session token returned from login>" -d "the description you want added/updated"
cookies = {"token": token}
response = requests.put(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description",
data='the description you want added/updated'
cookies=cookies
)
Delete an Access Token for Service Accounts
Use this endpoint to delete an access token. This will require you to know the token_id you wish to adjust which can be found in the list of access tokens described above.
curl -X DELETE https://<your_organization>.silect.is/api/magpie/access-token/<token_id>/description \ -H "Authorization: token <the session token returned from login>"
cookies = {"token": token}
response = requests.delete(
"https://<your_organization>.silect.is/api/magpie/access-token/<token_id>",
cookies=cookies
)
Rotate Access Tokens for Service Accounts
Use this endpoint for easy rotation of the access token associated with a service account. This will delete all current access tokens and return a single access token.
curl -X POST https://<your_organization>.silect.is/api/magpie/access-token/rotate/<user name> \ -H "Authorization: token <the session token returned from login>"
cookies = {"token": token}
response = requests.post(
"https://<your_organization>.silect.is/api/magpie/access-token/rotate/<user name>",
cookies=cookies
)