+1 (855) 920-2583
Login

APS REST API with oAuth fails with 403 error.

Modified on: Fri, 17 Nov 2023 12:07 PM
Original Publishing Date:
2020-01-22

Symptoms

Any requests to the APS REST API fails with 403 error if oAuth authorization is used.

Cause

oAuth authorization requires HTTPS protocol to operate as described in the documentation.

Resolution

In order to make it work, we have to create the brand and send the request via HTTPS protocol to the brand URL.

E.g. create the brand "cats.tld", add this record to the hosts file and use the following script to send request:

from requests_oauthlib import OAuth1Session

# Enter input parameters:
consumer_key = 'DJ0wWDJarXbzK5iITucFkmcUGWfCrcsY'
consumer_secret = 'zkRDUTA1V8GFdbvkViWnk3PvITcvz***********InTYs5VyJNMO8ZQL6UVof2Nu6g'
url = "https://cats.tld/aps/2/resources/"

# Set session parameters and get response:
session = OAuth1Session(consumer_key, consumer_secret)
response = session.get(url, verify=False)
print response.text

Internal content