Getting Started
Getting started with using Electrification X APIs involves the following steps:
- Get credentials for authorization
- Create a JSON Web Token (JWT) by using the credentials
- Make API requests using the JWT
Get credentials¶
Contact your company administrator. Your company administrator will provide you with the following credentials:
- Client id
- Client secret
Create a token¶
For the Electrification X API you need a client id and a client secret to get an access token.
Example request¶
import requests
def authenticate(client_id: str, client_secret: str) -> str:
response = requests.post('https://siemens-bt-015.eu.auth0.com/oauth/token', payload={
'client_id': client_id,
'client_secret': client_secret,
'audience': 'https://horizon.siemens.com',
'grant_type': 'client_credentials',
})
response.raise_for_status()
message = reponse.json()
return message['access_token']
Example response¶
{
"access_token": "eyJ0eXAiOiUSJ9.eyJpc3MiOiJdGlhbHMifQ.MJpcxLfyOt",
"token_type": "Bearer",
"expires_in": 86400
}
The access token is a JWT (JSON Web Token). It is the value of the access_token-property in the response. You can now use it by passing it in the Authorization-header of any subsequent API requests. The expires_in-property represents the number of seconds your token is valid. Usually, the value corresponds to 24 hours. When this time has elapsed you will need to create a new token.