Authentication

The REST API uses authentication and authorization to prevent unauthorized access to gateways and their peripherals.

The Microsoft identity platform, Microsoft’s cloud-based identity and access management (IAM) solution, and in particular Microsoft Entra ID, are used to protect the API.

A third-party software application must pass a valid access token (JWT) with every API call. The REST API validates the token before allowing the call to execute. To generate a valid token, an application must first be registered in Entra ID and an authentication flow must be defined. Although multiple OAuth 2.0 flows are possible, Alphatronics supports only the OAuth 2.0 client credentials flow for backend-to-backend API communication.

For registration of the third-party application in Entra ID, two scenarios are possible:

  1. A new Entra ID tenant is created and managed by Alphatronics representing the software integrator.

  2. The software integrator’s EntraID is used.

In both cases, the following steps are required:

  1. Register the GW Cloud API as an Enterprise Application in the software integrator’s Entra ID tenant, thereby creating a service principal for the GW Cloud API in the integrator’s tenant. The GW Cloud API is registered as a multitenant API in the Alphatronics Entra ID tenant.

  2. Allow the software integrator’s Entra ID tenant to access the GW Cloud API registered in the Alphatronics Entra ID tenant.

  3. Register the software integrator’s application as an App Registration in the software integrator’s Entra ID tenant. This enables the software integrator to configure an OAuth 2.0 client credentials flow that allows the application to generate a JWT used in GW Cloud API calls.

  4. Grant the registered application permission to call the GW Cloud API. This ensures that the JWT contains the required claims.

The table below provides an overview of the relevant Entra ID objects:

Object

Where

Owned by

Purpose

API app registration

Alphatronics tenant

Alphatronics

Defines the GW Cloud API

API enterprise application

SW Integrator tenant

SW Integrator or Alphatronics

Local representation of the GW Cloud API

Client app registration

SW Integrator tenant

SW Integrator or Alphatronics

Identity of the SW Integrator application

Client secret/certificate

SW Integrator tenant

SW Integrator or Alphatronics

Credential for the SW Integrator application

Get token

Once the security infrastructure described above is set up and configured correctly, the third-party application can generate an access token as follows.

request (using client secret)

POST https://login.microsoftonline.com/<sw-integrator-tenant-id>/oauth2/v2.0/token

//headers
Content-Type: application/x-www-form-urlencoded

//body
client_id=<sw-integrator-application-id>&
client_secret=<sw-integrator-application-client-secret>&
grant_type=client_credentials&
scope=api%3A%2F%2%2F<gw-cloud-api-application-id>.default

response

HTTP/1.1 200 OK
...

{
    "token_type":"Bearer",
    "expires_in":3599,
    "ext_expires_in":3599,
    "access_token":"..."
}

The returned token must be passed in the Authorization header of every API call in the following format: Bearer <access_token>.