Skip to content

Instantly share code, notes, and snippets.

@guanix
Created October 5, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guanix/6e2cd5c68ac4e0204f246f769256e278 to your computer and use it in GitHub Desktop.
Save guanix/6e2cd5c68ac4e0204f246f769256e278 to your computer and use it in GitHub Desktop.
Zoey REST API request in Python
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