Developer Documentation
  • Documentation Overview
  • Development Introduction
  • Getting Started
  • Fundamentals
    • Deploy an App via Pre-defined Sidecar
      • Sidecar Tutorial: Server-side
      • Sidecar Tutorial: Client-side
      • Sidecar Tutorial: Docker & Deploy
    • Deploy an App with Eureka
    • Design Guidance
  • Authentication
    • Accessing data exposed by the platform
    • Single Sign-On
      • Angular
      • Vue
      • Java Spring: Accepting JWT
      • Python Django: Accepting JWT
    • User and Role Identification
  • APIs | Data Integration
    • Submodel Index
    • Masterdata
    • Transactional data
  • Docker Information
    • Ruby Stack
    • Golang Stack
    • Node JS Stack
    • Java Spring Stack
    • Python Stack
  • Connect to the Platform
    • Integrate using Eureka Rest APIs
    • Use our Pre-built sidecar
    • Production deployment
  • Add-on Features
    • IApps-Navigation
  • Testing
  • FAQs | Troubleshooting
  • Registration
    • Application pre-requisites
      • Basic Requirements
    • Register Developer Account
    • Submit basic application info
    • Onboard Application
      • Submit Appstore details
        • App basic information
      • Configure Application
        • App Permission
        • App Data
        • AAS Instance
        • Licensing
        • Access Rights
        • Account Info
        • Terms Of Use
        • Pricing
      • Publish and test
        • Deploy
        • Register into Service Discovery
    • Publish to Marketplace
  • User Experience
  • The business model - How do I get paid?
  • References
    • IndustryApps - Intro
    • What is an Asset Administration Shell?
    • What is ECLASS?
      • How is ECLASS and Concept dictionary are used
    • Industry 4.0 standards
    • Customer Terms of Use
      • Subscription Order
    • Solution provider Terms of Use
      • Contract regions
      • Submission Form ( Solution provider)
Powered by GitBook
On this page

Testing

To test your application locally, demo user context can be used to observe functionality. The platform-api.js function getPlatformContext cannot be used outside of the platform scope, you can test the application with platform context by contacting our team and receiving access to a demo customer portal for this purpose.

// Demo user context to test functionality locally.
{
    "auth_token": "eb837c91-bee4-4011-8af5-1f7af649be92",
    "euser": "heera@xeiex.com",
    "plant_selected": "1",
    "language_selected": "en",
    "plant_list": [
        {
            "plantId": 2,
            "plantName": "Kilsyth",
            "plantCode": "5698",
            "defaultPlant": false
        },
        {
            "plantId": 1,
            "plantName": "Brisbane 01",
            "plantCode": "0987",
            "defaultPlant": true
        }
    ],
    "company_code": "1234",
    "roles": [
        "GRP_M_ADD",
        "TOOL_CRD_VIEW",
        "SOP_A_VIEW",
        "TSOP_M_ADD",
        "QSOP_IU_DEL",
        "OPR_ACT_ADD",
        "VENDOR_M_EDIT",
        "PROC_TYP_M_DEL",
        "QSOP_V_VIEW",
        "COM_M_EDIT",
        "DTC_EDIT",
        "8e08d9_Add_VIEW",
        "MACH_M_EDIT",
        "SOP_M_ADD",
        "QC_VIEW"
    ]
}

App (Client Token)

As mentioned in 'Accessing Masterdata', both an application token (client token) and a user token (auth_token) are required to be able to utilise AAS and Submodel data. A demonstration of retrieving the Application token is demonstrated below.

"""
Python Sample Code, retrieving App token, this must be either refreshed
automatically every 30 seconds by scheduling execution in app or by 
requesting a new token.
"""
def get_access_token():
    INDUSTRY_API_URL = 'https://auth.uat.industryapps.net/auth/realms/IndustryApps/protocol/openid-connect/token'
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    body = {
        "grant_type": "client_credentials",
        "client_id": "<<App ID>>",
        "client_secret": "<<App Secret Code>>"
    }
    token = requests.post(INDUSTRY_API_URL, data=body, headers=headers)
    token_response_data = token
    try:
        access_token = token_response_data['access_token']
        return access_token
    except:
        return token_response_data
// Javascript example using the Fetch API
const data = {  "grant_type": "client_credentials",
                "client_id": "<<App ID>>",
                "client_secret": "<<App Secret Code>>" 
              };
const INDUSTRY_API_URL = 'https://auth.uat.industryapps.net/auth/realms/IndustryApps/protocol/openid-connect/token'
fetch(INDUSTRY_API_URL, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: data,
})
.then((response) => response.json())
.then((data) => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});

As a reminder, the App ID and App Secret Code are available by navigating onto your app dashboard > App Information:

Note that the access token will not be available outside the demo customer portal or platform scope, resulting in an invalid token response while hosting the application externally.

Once the application has access to its app and user context token, integrating Masterdata or Transactional data from the platform to test and implement functionality is worked through calling the available endpoints.

# Fetching AAS List from the platform.
def get_aas_list(asset_type, plantcode):
    # App Token Generation
    access_token = get_access_token()
    # Retrieving stored user context from temporary Redis Cache
    user_context = rs.get("user_information")
    extract_user = json.loads(user_context)
    user_token = extract_user["auth_token"]
    # Required Tokens for a successful response.
    headers = {
        "Authorization": 'Bearer ' + access_token,
        "UserToken": 'Bearer ' + user_token
    }
    # Set Asset Type & Plant Code in func params
    params = {
        "AssetType": asset_type, 
        "PlantCode": plantcode
    }
    try:
        res = requests.get(AAS_LIST_URL, headers=headers, params=params)
        return res
    except Exception as e:
        print(e)

Local & Production deployment

PreviousIApps-NavigationNextFAQs | Troubleshooting

Last updated 2 years ago

Postman

Platform context endpoints can be experienced by forking the . The app and user tokens should be added in the environment of the forked collection.

The application can be connected via the , and have the container image pushed onto the platform. Once the app has been onboarded, user experience can be tested via a demo customer portal as part of the Vendor registration process. You will receive a trial user id and password for the developer store and smart factory platform.

IndustryApps Postman collection
pre-defined sidecar
Eureka endpoints
Generate a client secret.