Authentication
You can use any API tools to manage cards with Axidian CertiFlow API. This article describes how to configure API authentication in Swagger, Postman, Windows Powershell and Linux Bash.
Select the instruction depending on the authentication type configured in the Axidian CertiFlow Configuration Wizard.
- Windows
- OpenID Connect
Check authentication settings
- Launch the IIS Manager and select Default Web Site in the left menu.
- Expand the CertiFlow applications list and select the api application.
- In the application control panel, select the Authentication property and make sure that Windows Authentication is set.
- Close the IIS Manager.
- Open the C:\inetpub\wwwroot\certiflow\api\appsettings.json configuration file and make sure that the
authenticationparameter is set toWindows.
Swagger
To use Swagger, set up the API configuration file:
- Navigate to the C:\inetpub\wwwroot\certiflow\api catalog and open the appsettings.json file.
- In the
webApiSettingssection, set theenableSwaggerparameter totrueand save the changes. - Apply changes to the Axidian CertiFlow Server.
Swagger is available at https:///certiflow/api/swagger.
Postman
Postman is available as a desktop or a web application. The instruction below describes how to configure authentication in the Postman desktop application.
- Click Add in the workbench to open a new tab.
- Go to the Auth tab and select NTLM Authentication.
- Enter the username and password.
- Select the request type and specify the request URL.
- Click Send.
Check authentication settings
To check API authentication settings on the Axidian CertiFlow Windows server:
- Launch the IIS Manager and select Default Web Site in the left menu.
- Expand the CertiFlow applications list and select the api application.
- In the application control panel, select the Authentication property and make sure that Anonymous Authentication is set.
- Close the IIS Manager.
- Navigate to the C:\inetpub\wwwroot\certiflow\api catalog and open the appsettings.json file.
- Make sure the
authenticationparameter is set toOAuth2Introspection.
To check API authentication settings on the Axidian CertiFlow Linux server:
- Navigate to the /opt/axidian/certiflow/api catalog and open the appsettings.json file.
- Make sure the
authenticationparameter is set toOAuth2Introspection.
Swagger
To use Swagger, set up the API configuration file:
- Navigate to the C:\inetpub\wwwroot\certiflow\api catalog in Windows OS or /opt/axidian/certiflow/api in Linux OS and open the appsettings.json file.
- In the
webApiSettingssection, set theenableSwaggerparameter totrue. - Save the changes.
- Apply changes to the Axidian CertiFlow Server.
To authenticate in Swagger:
- Open your browser and go to
https:///certiflow/api/swagger. - Click Authorize.
- In the Scopes string, click Select all.
- Click Authorize.
Postman
Postman is available as a desktop or a web application. The instruction below describes how to configure authentication in the Postman desktop application.
To configure authentication in Postman:
- Click Add in the workbench to open a new tab.
- Navigate to the Auth tab and select OAuth 2.0.
- Leave the Add auth data to field value as default.
- In the Current Token section, leave the Header Prefix field value as default.
- In the Configure New Token section, specify the data to obtain an access token:
- Token Name – specify the token name.
- Grant Type – select Password Credentials.
- Access Token URL – specify the link to obtain an access token:
https:///oidc/connect/token. - Client ID – specify the
WebApiClientservice identifier. - Username – specify the username in the
Domain\Usernameformat. - Password – specify the user password.
- Client Authentication – select Send as Basic Auth header.
- Click Get New Access Token.
- Click Use Token.
To make an API request:
- Select the request type.
- Specify the request URL.
- Click Send.
Windows Powershell
To work with the API through Powershell, use Powershell scripts.
Obtain an access token and make a request:
Open the terminal or a Powershell script file and prepare the following parameters.
$body = @{grant_type='password'; username='Domain\Username'; password='P@ssw0rd'; scope='openid webapi';client_id='WebApiClient' }
$url="https://<FQDN сервера Axidian CertiFlow>/oidc/connect/token"Extract the access token from the response.
$resp = Invoke-RestMethod -Method Post -Uri $url -Body $body -UseDefaultCredentials
$token = $resp.access_tokenAdd the token to the request header.
$headers = @{Authorization="Bearer $token"}Make a request.
Invoke-RestMethod -Method Get -Uri $url -Headers $headers -UseDefaultCredentials
Linux Bash
To work with the API through Linux Bash, use Bash scripts.
Obtain an access token and make a request:
In the terminal or in a Bash script file, prepare the following parameters.
username="DOMAIN\\username"
password="P@ssw0rd"
base_url="https://<FQDN сервера Axidian CertiFlow>"
body="grant_type=password&username=$username&password=$password&scope=openid%20webapi&client_id=WebApiClient"
token_url="$base_url/certiflow/oidc/connect/token"
2. Extract the access token from the response.
```bash
resp=$(curl -s -X POST $token_url -H "Content-Type: application/x-www-form-urlencoded" --data $body)
token=$(echo $resp | grep -o '"access_token": "[^"]*' | cut -d'"' -f4)
Add the token to the request header.
headers="Authorization: Bearer $token"Make a request.
GET request examplecurl -X GET "$base_url/certiflow/api/Cards?state=Issued&offset=0&count=0" -H "$headers" -d ''POST request examplecurl -X POST "$base_url/certiflow/api/Cards/123/Enable" -H "$headers" -d ''
Bash script example
#!/bin/sh
#User input
username="DEMO\\admin"
password="P@ssw0rd"
base_url="https://certiflow-test.local"
body="grant_type=password&username=$username&password=$password&scope=openid%20webapi&client_id=WebApiClient"
token_url="$base_url/certiflow/oidc/connect/token"
# Get token
resp=$(curl -s -X POST $token_url -H "Content-Type: application/x-www-form-urlencoded" --data $body)
# Parse token
token=$(echo $resp | grep -o '"access_token": "[^"]*' | cut -d'"' -f4)
# Combine header
headers="Authorization: Bearer $token"
# Test enable card (POST)
curl -X POST "https://certiflow-test.local/certiflow/api/Cards/123/Enable" -H "accept: */*' -d ''
# Test Get enabled card (GET)
curl -X GET "https://certiflow-test.local/certiflow/api/Cards?state=Issued&offset=0&count=0" -H "accept: text/plain"