ki_rag_classify / _ecodomus.py
elia-waefler's picture
Upload 17 files
c2b923e verified
import requests
import urllib.parse
import os
# Assuming environment variables are used to store sensitive data
client_id = 'Siemens.Advanta'
client_secret = os.environ.get('SIEMENS_API_KEY')
username = "I0340828"
password = os.environ["SIEMENS_EW_PW"]
# Endpoint
url = "https://eu-ecodomus-services.siemens.com/api/token HTTP/1.1"
# Data needs to be URL-encoded
data = {
'client_id': client_id,
'client_secret': client_secret,
'username': username,
'password': password,
'grant_type': 'password'
}
encoded_data = urllib.parse.urlencode(data)
print(encoded_data)
# Headers
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
# POST Request
response = requests.post(url, data=encoded_data, headers=headers)
print("Status Code:", response.status_code)
print("Response Content:", response.text)
print("content", response.content)
if response.status_code == 200:
access_token = response.json().get('access_token')
print("Access Token:", access_token)
else:
print("Failed to fetch access token. Check response content for details.")