This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TI-API: Python, Sandbox Backlog Order API error 401

Part Number: TI-API

Dear Support Team, I am writing to report an issue that I encountered while using the Texas Instruments (TI) Backlog API Python template.

Problem Description:

The issue pertains to the API authentication process. Although I have successfully obtained an access token, I am unable to access certain functionalities of the API, such as placing orders. This issue is impeding my ability to fully utilize the Backlog API for our operations. 

Error Details:
Here is the error message I received:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PS C:\Davidlocal> & C:/Davidlocal/Apps/python.exe c:/Davidlocal/PMD_TI_BACKLOG/ExampleTI_2/python/TEST_BKGOrderConfirm.py
Welcome to the backlog API example script!
We will test the create and retrieve order functions using Python.
Please replace lines 233-239 with your own customer credentials.
Authentication Successful! Token: *MASKED*
Customer sold-to ID is *MASKED*.
API authentication ID is *MASKED*.
Test ID for order is *MASKED*.
WARNING: Unexpected HTTP status code 401.
{
"error": "invalid_client",
"error_description": "client_id or client_secret are not correct",
"error_uri": "See the full API docs at https://api-portal.ti.com/order-api-authentication"
}
Create Order: FAIL (90 ms).
Supplier order # is MISSING.
Test procedure will terminate now.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Despite successful authentication, I am unable to retrieve the quote data. (Sandbox endpoint and credentials were used.)

Please see my codes:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import json
import os
from datetime import datetime
from TI_Backlog_API_V2 import TI_Backlog_Orders
import textwrap
import requests
class Backlog_Example_Script():
def __init__(self, server, clientID, clientSecret, shipTo, soldTo, debug=True):
self.server = server
self.clientID = clientID
self.clientSecret = clientSecret
self.shipTo = shipTo
self.soldTo = soldTo
self.debug = debug
self.access_token = self.retrieve_access_token()
def retrieve_access_token(self):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And here is the py template i use: TI_BKG_PY_TEMPLATE

  • David,

    I'll provide an update on Monday.  In the meantime. be sure there are no spaces around your clientID or secret.

    Regards,

    Faye

  • Hi Faye, since the server reply with a token, I would assume the credentials are correct.

  • Hi David,

    Although you successfully received a token,  there may be something wrong with the URL, because the error you are receiving never made it to our side.  Can you send me the full token server URL?   Also, please send me the server name that you are trying to connect.  Thanks!  

  • Please see the server URL
    I was using sandbox credential to access sandbox (transact-pre).
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Here is the URL:
    backlog_example = Backlog_Example_Script(
    · · server='transact-pre.ti.com/.../accesstoken',
    · · clientID='xxxxxx',
    · · clientSecret='xxxxxx',
    · · shipTo='xxxxxx',
    · · soldTo='xxxxxx',
    · · payerID='xxxxxx',
    · · debug=True ·# Set to True to always view server responses.
    )
    Thanks!
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    https://transact-pre.ti.com/v1/oauth/accesstoken
  • David,

    I'll send you a private chat, as I would like to get all of the code. 

  • Hi David,

    Closing this thread, per our conversation.  Glad everything is working now!   Just to summarize the problem and solution:

    You had:  

    • auth_endpoint = f"{server}/v2/oauth/token"

    You needed:

    • auth_endpoint = f"{server}/v1/oauth/accesstoken"
    • server= "">https://transact-pre.ti.com"

    Let us know if you need anything else.

    Regards,

    Faye

**Attention** This is a public forum