Creating access tokens
You must create an access token for a client that needs to access the endpoints of a given Web API service. Access tokens are only valid for 30 minutes; if you restart the Web API, existing tokens become invalid at once. If token expires, you must create a new one.
In actual integration, building access tokens must be part of the integration software. For testing purposes, you can build them with any suitable software, such as Windows PowerShell or Insomnia.
Prerequisites
-
Name, Client ID, and Secret Key of the client. These are defined when creating a new client, as described in Adding clients.
Code example
The following Windows PowerShell code returns an access token. In the fields URL, Name, ClientID, and ClientSecret, replace the values with values from your project.
$Url = "http://localhost:25001/api/token"
$Body = @{
Name = "Client_1"
ClientID = "4A21D8D846BF98541184BEB96802BD9D"
ClientSecret = "irjdgoE9Dqa4KdAladbO5zSB7JOo8IHQWO8NwAhqxz8="
} | ConvertTo-Json
Invoke-RestMethod -Method 'Post' -Uri $Url -Body $Body -ContentType "application/json"
An example access token returned by the script:
token ----- eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzY2NjgxNDN9.XyxYgHqjn8Q2Moz2B3dANixII-7LpDbabhpTywHEDow