Request authentication
Depending on the product or its resource, the following are used to work with Servercore product APIs and authenticate requests instead of a username and password:
-
IAM tokens — issued to service users and Control Panel users. Token lifetime is 24 hours. IAM tokens are passed in the
X-Auth-Tokenheader and have different scopes:- IAM tokens for an account (
iam_token_account_scoped) — for managing resources attached to an account; - IAM tokens for a project (
iam_token_project_scoped) — for managing resources attached to a project;
- IAM tokens for an account (
-
static tokens (
static_token) — issued to Control Panel users and used to manage resources attached to an account. Token lifetime is unlimited. Static tokens are passed in theX-Token.
You can find the URL for requests in the Authentication section of the URL List manual.
You can limit access to the API for endpoints that include https://api.servercore.com.
Account-scoped IAM token (X-Auth-Token)
The token is passed in the X-Auth-Token header.
An IAM token for an account (iam_token_account_scoped) provides access to managing most Servercore products and OpenStack API objects on par with a username and password in the my.servercore.com Control Panel. It allows managing account resources.
Token lifetime is 24 hours.
The token allows managing:
- users and roles (IAM) and federations;
- balance and consumption statistics;
- dedicated servers;
- OpenStack API objects (cloud servers, network volumes, and others) using the API for cloud platform projects and resources, project quotas and limits, learn more in the OpenStack documentation;
- global router.
Get an IAM token for an account
To authenticate in work tools, create a service user and get an IAM token for the account. To get an IAM token for a control panel user, use the Manage IAM tokens subsection of the Manage access keys instructions. We recommend using control panel user IAM tokens only for testing.
To get an IAM token for an account, the user must have a permission where the selected scope is Account.
If you are using Windows, replace single quotes ('') in requests with double quotes (""). We also recommend using PowerShell for requests instead of CMD.
- Send the following request:
curl -i -XPOST \
-H 'Content-Type: application/json' \
-d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"<username>","domain":{"name":"<account_id>"},"password":"<password>"}}},"scope":{"domain":{"name":"<account_id>"}}}}' \
'https://cloud.api.servercore.com/identity/v3/auth/tokens'
Specify:
<username>— service user name. You can view the name in the Control Panel: in the top menu, click IAM → the Service Users section (the section is available only to the Account Owner and a user with theiam.adminrole);<account_id>— account number. You can find it in the Control Panel in the upper-right corner;<password>— service user password; you can view it when creating a user or change it to a new one.
Upon successful authorization, a response with code 201 Created will be returned in the following format:
HTTP/2 201
X-Subject-Token: token
- Find the token in the
X-Subject-Tokenheader.
Project-scoped IAM token (X-Auth-Token)
The token is passed in the X-Auth-Token header.
An IAM token for a project (iam_token_project_scoped) provides access to managing most Servercore products and OpenStack API objects on par with a username and password in the my.servercore.com Control Panel. It allows managing project resources.
Token lifetime is 24 hours.
The token allows managing:
- dedicated servers;
- OpenStack API objects (cloud servers, network volumes, and others) using the API for cloud platform projects and resources, project quotas and limits, learn more in the OpenStack documentation;
- cloud platform — direct public IP addresses, Private DNS, Managed Databases, Managed Kubernetes, secrets manager (secrets, certificates);
- S3 (Swift API and Object Storage API);
- audit logs.
Get an IAM token for a project
To authenticate in work tools, create a service user and get an IAM token for the project. To get an IAM token for a control panel user, use the Manage IAM tokens subsection of the Manage access keys instructions. We recommend using control panel user IAM tokens only for testing.
To get an IAM token for a project, the user must have a permission where:
- the selected scope is Account;
- or the selected scope is Projects and the required project is selected.
If you are using Windows, replace single quotes ('') in requests with double quotes (""). We also recommend using PowerShell for requests instead of CMD.
- Send the following request:
curl -i -XPOST \
-H 'Content-Type: application/json' \
-d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"<username>","domain":{"name":"<account_id>"},"password":"<password>"}}},"scope":{"project":{"name":"<project_name>","domain":{"name":"<account_id>"}}}}}' \
'https://cloud.api.servercore.com/identity/v3/auth/tokens'
Specify:
<username>— service user name. You can view the name in the Control Panel: in the top menu, click IAM → the Service Users section (the section is available only to the Account Owner and a user with theiam.adminrole);<account_id>— account number. You can find it in the Control Panel in the upper-right corner;<password>— service user password; you can view it when creating a user or change it to a new one;<project_name>— project name.
Upon successful authorization, a response with code 201 Created will be returned in the following format:
HTTP/2 201
X-Subject-Token: token
- Find the token in the
X-Subject-Tokenheader.
Static token (X-Token)
An X-Token can only be issued to a Control Panel user.
The token is passed in a request in the X-Token header.
A static token (static_token) provides full access to managing certain Servercore products on par with a username and password in the my.servercore.com Control Panel. It does not allow managing OpenStack API objects.
The token lifespan is unlimited.
For APIs that do not support an IAM token for an account and an IAM token for a project, the static token is the only option:
Get a static token
- In the Control Panel, open the menu (account number) in the upper-right corner and select Profile.
- Go to the Access section → API Keys tab.
- Click Add Key.
- Enter the key name.
- Click Add.