Generating an authorization token
General
This method allows you to generate a JWE token using a private key obtained in RuStore Console. The method also checks the app owner’s activities.
A private key is required to successfully complete the request.
Interaction parameters
POST /public/auth/
From July 30 onward, the companyId
parameter for authorization will be deprecated. Use keyId
to obtain your authorization token.
Attribute | Type | Required | Location | Description | Example |
---|---|---|---|---|---|
companyId | string | Yes, if keyId is not specified | body | Company id . This parameter will be unavailable from July 30, 2024. | 123 |
keyId | string | Yes, if companyId is not specified | body | Key id | 123 |
timestamp | string | Yes | body | Response time delay should not exceed 60 seconds compared to the current server time. | 2022-07-08T13:24:41.8328711+03:00 |
signature | string | Yes | body | RSA-signature SHA-512 hash in a line that contains companyId and timestamp of a response. Signature layout and verification algorithm: SHA512withRSA. Example: • companyId : 123 • timestamp : 2022-07-08T13:24:41.8328711+03:00 • String for hash: 1232022-07-08T13:24:41.8328711+03:00 • SHA-512 hash : 0976c61...033235 | N/A |
If you have problems understanding the signature
parameter algorithm, use keyId
instead of companyId
to generate this parameter.
You need to pass the company id and the resulting private key. In response, you will receive a body for the POST request /public/auth/ with companyId, timestamp and signature parameters.
.jar-file for companyId;
.jar-file for keyId.
You need to pass the company id and the resulting private key. In response, you will receive a body for POST /public/auth/
with companyId
/keyId
, timestamp
and signature
..
The generated signature parameter is valid for 1 minute, since it directly depends on the timestamp
.
Response example
Attribute | Type | Required | Description | Example |
---|---|---|---|---|
code | string | Yes | Response code | error /OK |
message | string | No | Error response | Range timestamp not valid |
body{} | object | Yes | N/A | N/A |
timestamp | timestamptz | Yes | Response time | 2022-07-08T13:24:41.8328711+03:00 |
body
Attribute | Type | Required | Description | Example |
---|---|---|---|---|
jwe | string | Yes | Security token to API RuStore (payload is below). Re-usable | eyJjdHkiOiJK…sv16aBl8tTg.VkWuTw |
ttl | int | Yes | Token validity period, sec By default, the token validity periods are set to 900 seconds | 900 |
Possible errors
code | message | Description | Possible errors |
---|---|---|---|
400 | Range timestamp not valid | The timestamp parameter differs by more than 60 seconds | Update timestamp and signature |
404 | Company key not found | The private key was not found for the transmitted companyId | Check whether a private key has been created for this companyId and whether it is up to date |
400 | Company key disabled | The private key for the transferred companyId has been deleted | Check whether a private key has been created for this companyId and whether it is up to date |
400 | Signature encode error | The signature parameter was generated incorrectly | Regenerate the signature parameter |
404 | You cannot use this action because the company is not found | The company that corresponds to the passed companyId is missing or inactive | Check the companyId parameter to ensure it is up to date |
400 | You can't use this action because the company is banned | The company with the transferred companyId is blocked | Check the companyId parameter to ensure it is up to date |
400 | KeyId or companyId must be not null | Check keyId or companyId to ensure one of them is up to date | Check keyId or companyId parameter to make sure that one of them is specified. |
400 | Incorrect usage of companyId. Please use keyId | You have more than one private key created, you must use the keyId parameter. | Use the keyId parameter. |
Request example
curl --location 'https://public-api.rustore.ru/public/auth' \
--header 'Content-Type: application/json' \
--data '{
"companyId":"1275328",
"timestamp":"2023-08-11T13:31:17.580+03:00",
"signature":"U4kh.......nFkbuw=="
}
Successful response
{
"code": "OK",
"message": null,
"body": {
"jwe": "eyJlbmMiOiJBM......nuuM227D_O1A",
"ttl": 900
},
"timestamp": "2023-08-11T13:31:33.171847393+03:00"
}