This thread has been locked.

TI-API: Python API implementation: issues with token and status evolution



import requests
import json

''' Authentication and Token request'''
urlAuthentication = "https://transact.ti.com/v1/oauth/accesstoken"
header = {"Content-Type": "application/x-www-form-urlencoded" }
auth_info = {   'grant_type' : 'client_credentials',
                'client_id' : "..................",
                'client_secret' : "...............",
            }
response = requests.post(urlAuthentication, auth_info, headers=header)
response_dict = response.json()
print("Authentication response: ", response)
print('TOKEN: ' , json.dumps(response_dict, indent=4, sort_keys=True))

'''Header'''
headers = { "Authorization" : "", 'accept': 'application/json', 'Content-Type': 'application/json'}
headers["Authorization"] = response_dict["access_token"]
#print(headers)

urlItem =  https://transact.ti.com/v2/store/products/TFP401APZPR?currency=USD&exclude-evms=true'
urlOrder = "https://transact.ti.com/v2/store/orders/test"
urlGetOrder = "https://transact.ti.com/v2/store/orders/T04600586/advanced-shipment-notices/test"   #startDate=2021-08-01&endDate=2023-11-01"


data = {   
            "order": {
                    "checkoutProfileId": "04CC5D94F05B17CEE063DE21BB8B27ED",
                    "customerPurchaseOrderNumber": "IC/TFP401A",
                    "endCustomerCompanyName": "Control iD",
                    "expediteShipping": False,
                    "customerOrderComments": [
                        {
                        "message": "MY TEST ORDER"
                        }
                    ],
                    "lineItems": [
                        {
                            "customerLineItemNumber": 1,
                            "tiPartNumber": "TFP401APZPR",
                            "customerPartNumber": "IC/TFP401A",
                            "customReelIndicator": False,
                            "quantity": 50
                        }
                    ]

            }
        }
        
        
'''Inventory pricing'''
url = 'https://transact.ti.com/v2/store/products?gpn=AFE7799&currency=USD&exclude-evms=true&page=0&size=20'
response = requests.get(url, headers = 	'accept': 'application/json'})
response_dict = response.json()
print(response)
print(json.dumps(response_dict, indent=4, sort_keys=True))


'''Order Request'''
response = requests.post(urlOrder, data = json.dumps(data), headers=headers)
response_dict = response.json()
print(response)
print(json.dumps(response_dict, indent=4, sort_keys=True))


'''Get Order List'''
response = requests.get(urlGetOrder, headers=headers)


response_dict = response.json()
print(response)
print(json.dumps(response_dict, indent=4, sort_keys=True))

Based on my conversation with Rainer Roese, the code mentioned earlier was functioning properly about a month ago. We were able to authenticate successfully, obtain an Access token, and even execute a test order without encountering any problems. However, the token obtained in the latest request is not working as expected, and the error message displayed below is quite concerning. Additionally, the TI team has informed us that the implementation process status is still incomplete, which is causing further delays. Could you please help me solve this problem?

<Response [401]>
    {
         "errors": [
                         {
                        "errorCode": "TI-API-0401",
                        "message": "Invalid Access Token. Learn more about Oauth here https://api-portal.ti.com/order-api-authentication or contact support",
                        "reason": "Invalid Credentials",
                        "type": "Security"
                         }
                       ]
    }

**Attention** This is a public forum