Created
October 5, 2020 15:20
-
-
Save guanix/6e2cd5c68ac4e0204f246f769256e278 to your computer and use it in GitHub Desktop.
Zoey REST API request in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests_oauthlib import OAuth1Session | |
import pprint | |
client_key = os.environ["ZOEY_CONSUMER_KEY"] | |
client_secret = os.environ["ZOEY_CONSUMER_SECRET"] | |
oauth_token = os.environ["ZOEY_OAUTH_TOKEN"] | |
oauth_secret = os.environ["ZOEY_OAUTH_SECRET"] | |
zoey = OAuth1Session( | |
client_key, | |
client_secret=client_secret, | |
resource_owner_key=oauth_token, | |
resource_owner_secret=oauth_secret, | |
) | |
url = "https://tsXXXXXX-container.zoeysite.com/api/rest/products" | |
r = zoey.get( | |
url, | |
headers={ | |
"Content-Type": "application/json", | |
"Accept": "application/json", | |
"User-Agent": None, | |
}, | |
) | |
r.raise_for_status() | |
pp = pprint.PrettyPrinter(indent=4) | |
pp.pprint(r.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment