Authorization Bearer
Before starting integration you need:
- Receive authorization keys from the manager (bearer token);
- Provide us with your servers' IP addresses to enter into our list of allowed IP addresses.
For Bearer authorization, JWT (JSON Web Token) is used, utilizing the HS256 algorithm. The token includes publicKey in the payload and is signed with the privateKey.
The payload of our JWT will include the following field:
publicKey: The public key that corresponds to the private key used to sign the JWT.
The privateKey is used to sign the JWT.
Example in Python:
Requirements
Install the pyjwt library using the command pip install pyjwt.
Code example:
import jwt
import datetime
//Define the payload with the public key
payload = {
"publicKey": "your-public-key-here",
"exp": datetime.datetime.utcnow() + datetime.timedelta(hours=1) # Token expiration time
}
//Your private key for signing the JWT
private_key = "your-private-key-here"
//Generate the JWT token
token = jwt.encode(payload, private_key, algorithm='HS256')
print("Generated JWT token:")
print(token)
Example in .NET Core:
Requirements
Install the System.IdentityModel.Tokens.Jwt package using NuGet.
Code example:
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using Microsoft.IdentityModel.Tokens;
class Program
{
static void Main()
{
// Define the payload with the public key
var claims = new[]
{
new Claim("publicKey", "your-public-key-here")
};
// Your private key for signing the JWT
var privateKey = "your-private-key-here";
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(privateKey));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
var token = new JwtSecurityToken(
issuer: "your-issuer",
audience: "your-audience",
claims: claims,
expires: DateTime.Now.AddHours(1),
signingCredentials: creds);
var tokenHandler = new JwtSecurityTokenHandler();
var jwt = tokenHandler.WriteToken(token);
Console.WriteLine("Generated JWT token:");
Console.WriteLine(jwt);
}
}
Last modified: a month ago