Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Authentication: Azure AD validates credentials and issues signed JWT tokens
  2. Role Check: Only apps with ExternalSystem.Access role can authenticate
  3. Route Restriction: External tokens limited to /api/external/* endpoints
  4. Company Authorization: Apps can only access their assigned company data

...

Authentication

OAuth2 Configuration

ItemValue
Token URLhttps://login.microsoftonline.com/
6073ce8b
f90faace-
73f3
b48d-
4df4
4a19-
9b80
a39c-
5e40cdc6965f
1dd7b37686e3/oauth2/v2.0/token
Client ID
1f018c75

11a51e47-

2ea9

cee5-

4d46

4bb6-

a4f1

882b-

a45d2d47d043

a669dfaf1cb8

Client SecretYOUR_CLIENT_SECRET
 (provided separately)
Grant Typeclient_credentials
Scopeapi://
4dad5d62
e85dc5b1-
dc8c
f01b-
4378
45bd-
8bd0
b48d-
ae736a4d73fe
08f50ee2e160/.default
Content-Typeapplication/x-www-form-urlencoded

Token Request

POST https://login.microsoftonline.com/6073ce8bf90faace-73f3b48d-4df44a19-9b80a39c-5e40cdc6965f1dd7b37686e3/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=1f018c7511a51e47-2ea9cee5-4d464bb6-a4f1882b-a45d2d47d043a669dfaf1cb8
&client_secret=YOUR_CLIENT_SECRET
&scope=api://4dad5d62e85dc5b1-dc8cf01b-437845bd-8bd0b48d-ae736a4d73fe08f50ee2e160/.default

Response:

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

Token Lifetime: 1 hour


...

API Usage (

...

Prod Environment)

Base Configuration

ItemValue
API Base URLhttps://apiservice.
gentledesert
redbay-
fcac7adc
6992b142.swedencentral.azurecontainerapps.io/api/external
AuthenticationAuthorization: Bearer <token>
Content Typeapplication/json

Endpoint: Get Turnaround Report

Retrieves work order turnaround data with status transitions.

GET /turnaround-report

Query Parameters:

NameTypeRequiredDescriptionExample
companyNumberstringYesCompany identifierSonlincXML3
dateFromstringNoStart date (YYYY-MM-DD)2025-01-01
dateTostringNoEnd date (YYYY-MM-DD)2025-12-31

Request Example:

GET /api/external/turnaround-report?companyNumber=SonlincXML3&dateFrom=2025-01-01&dateTo=2025-12-31
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...
Accept: application/json

Response (200 OK):

{
  "turnaroundReportItems": [
    {
      "workOrderID": 1503,
      "workOrderNumber": "E261503",
      "workOrderTypeID": 1,
      "workOrderType": "New Installation",
      "consumptionCategoryID": 1,
      "consumptionCategoryName": "Apartment",
      "preFuseAmpere": 10,
      "preFuseTypeID": 1,
      "preFuseType": "Switch",
      "workOrderStatusID": 2,
      "workOrderStatus": "Registration Sent",
      "timestamp": "2025-12-20T10:30:00Z"
    }
  ]
}

Response Fields:

FieldTypeDescription
workOrderIDintegerWork order identifier
workOrderNumberstringWork order number
workOrderTypestringType (e.g., "New Installation")
consumptionCategoryNamestringCategory (e.g., "Apartment")
preFuseAmpereintegerPre-fuse amperage
preFuseTypestringPre-fuse type
workOrderStatusstringStatus (e.g., "Registration Sent")
timestampstringISO 8601 timestamp

HTTP Status Codes:

CodeDescription
200Success
400Invalid parameters (e.g., date range > 5 years)
401Missing or invalid token
403Not authorized for this company
500Server error

Validation Rules:

  • Date range max 5 years
  • dateFrom must be ≤ dateTo

...

Configuration

Azure AD Setup

  1. Define API App Role

    Before external systems can be granted access, an App Role must be defined in the API App Registration.

    Go to:

    • Microsoft Entra IDApp registrations

    • Open EGU.PartnerPortal.ApiService

    Navigate to App roles → Create app role.

    Configure the role:

    FieldValue
    Display nameExternal System Access
    Allowed member typesApplications
    ValueExternalSystem.Access
    DescriptionAllows external systems to access turnaround report data

    Save the role.

  2. Create External System App Registration

    • Create a separate application registration for each external company.

      Go to:

      • Microsoft Entra IDApp registrations

      • Select New registration

      Configuration:

      SettingValue
      Name{CompanyName}-PartnerPortal-Access
      Supported account typesAccounts in this organizational directory only
      Redirect URILeave blank
  3. Generate Client Secret

      1. Open the newly created {CompanyName}-PartnerPortal-Access app.

      2. Navigate to Certificates & secrets.

      3. Click New client secret.

      4. Copy the secret value immediately and store it securely.

      ⚠️ The secret value cannot be viewed again after creation.

      Never commit secrets to source control.

  4. Assign Permissions

    • Add permission: EGU.PartnerPortal.ApiService
    • Select: ExternalSystem.Access
    • Grant admin consent

  5. Company Mapping (API side configuration)

    {
      "ExternalCompanies": {
        "Ravdex": {
          "AppId": "11a51e47-cee5-4bb6-882b-a669dfaf1cb8",
          "CompanyNumber": "YOUR_COMPANY_NUMBER",
          "Name": "Ravdex"
        }
      }
    }