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.

Getting response of Not authorized

Calling the Authorization API in: https://transact.ti.com/v1/oauth/accesstoken

I have valid credentials, which testing the Authorization from https://api-portal.ti.com/inventory-pricing-api using Authorize button it works.

However, from the code i get exception: The remote server returned an error: (401) Unauthorized.

and the web response inside the exception is


{
"error": "invalid_client",
"error_description": "client_id or client_secret are not correct",
"error_uri": "See the full API docs at ">api-portal.ti.com/order-api-authentication"
}

However the client_id and client_secret are valid !

Please assist, maybe the calling code is not correct but there is no code example of how to call the authorization API, maybe the urls are not accurate in some links.

Thanks,

Lior

  • I am getting the same error.

  • Hi Lior,

    You may be sending your credentials as a JSON payload, while the API is expecting Form URL-encoded data.

    Details on the authentication requirements can be found at https://api-portal.ti.com/order-api-authentication

    For reference, the body in a sample Insomnia request would look like the following:

    And the header should contain:

    If you continue to see the issue, please provide an example of the request you're sending (please without the key and secret).

    Best regards,

    Paul

  • Hi Paul,

    Thanks for answering, can you please check the following question.

    I think you and me are closer to the problem and the solution but we are still not there. I have read all instructions pages of TI several times before submitting the original forum question, including  https://api-portal.ti.com/order-api-authentication.

    The documentation is not good in an understatement, hence we have this conversation, other people faced the same problem, and for any person that asks a question tens other people dont ask and waste a lot of time trying to understand by themselves. Let's assume in the page of  https://api-portal.ti.com/order-api-authentication it would have written at the end of the page "send the 3 attributes of the data of the request in a urlencoded format" as it should have.

    Next step. You asked me "please provide an example", It is a wrong question, The question should come from me and it is:

    Paul, please provide an official example of how to call the API. When mentioning the urlencode format, it might want different URL and it might want a very accurate data. Tried many strings all fail.

    Let's assume my client_id is called CLIENT_ID_VALUE and client_secret called CLIENT_SECRET_VALUE.

    You need to provide me with 2 strings (Texts), not screenshots of the TI web page and not the Insomnia web test page.

    1) String 1: What is the final URL to call integrating the 3 attributes inside it or not integrating the 3 attributes inside, but final URL?

    2) String 2: What is the final encoded string to send, which in the middle of it there are also CLIENT_ID_VALUE and CLIENT_SECRET_VALUE?

    Please respond with the accurate 2 strings, and I will replace in the 2 strings my private client id and client secret.

    The answer should be something like the below 2 strings (they are invented, just to emphasize the answer format)

    1) https://transact.ti.com/v1/oauth/accesstoken...........

    2) aabbcc##%%^%^&ERGFCLIENT_ID_VALUEGFHhyfhtysdfe53465CLIENT_SECRET_VALUEaderwr

    Thanks, Lior

  • Hi Lior,

    Thanks for the feedback. I hope the following helps to resolve your issue.

    • The URL to generate token is https://transact.ti.com/v1/oauth/accesstoken
    • When you pass in “form-urlencoded” payload it should be in this format:
      "grant_type=client_credentials&client_id=<your key>&client_secret=<your secret>"

    Below is the full curl command that you can use to generate the oAuth token:

       curl --request POST \
           --url transact.ti.com/.../accesstoken \   
           --header 'Content-Type: application/x-www-form-urlencoded' \   
           --data grant_type=client_credentials \   
           --data client_id=<your key> \   
           --data client_secret=<your secret>

    Let us know if you continue to have any issues.

    Best regards,
    Paul

  • Thanks for the help,

    It works good now after several attempts. Suggestion to add the below explanation to the API official web page, and also to the software developers that will face the same problem can read the below:

    1) The URL should be https://transact.ti.com/v1/oauth/accesstoken without any additional encoded parameters in it, just this URL as is.

    2) The 3 data attributes should be in a long string separated only by the character &, without any further encoding.

    Example, Assuming we have CLIENT_ID and CLIENT_SECRET then the final string to send in the web request should be:

    grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET

  • Hi Pankaj, have you been able to resolve your authentication issue from the discussion below?

    Thanks,

    Paul

  • Hi Paul / Lior ,

    Is my client ID = checkout profile id or KEY ( mentioned alongside client secret ).

    Anyway I tried using both but i am still not authenticated.

    Any idea why ?

    Thanks,

    Pankaj 

  • Hi Pankaj,

    It looks like you've had a few successful requests since you submitted this message. It's key that the request parameters are sent in the request body rather than as query parameters. Since this thread began, the description of this requirement has been updated at https://api-portal.ti.com/store-api-authentication to hopefully make that more clear.

    Let me know if you continue to have trouble.

    Thanks,

    Paul

  • Hi Paul,

    Yes, I was able to make successful calls.

    All thanks to updated document.

    Thanks,

    Pankaj S

**Attention** This is a public forum