Reputation: 195
I am hitting a Magento url by advance rest client, and passing some of the auth params like: consumer_key, consumer_secret , access token and access secret token. Signature method and nonce is there automatically. I want to hit the same by python to get the response. Request type is GET. How to pass these params with the python code?
Upvotes: 1
Views: 552
Reputation: 91
I'm hitting the Magento REST API from python using the Requests library and requests_oauthlib.
Something roughly along these lines:
import requests
from requests_oauthlib import OAuth1
def make_get_request(path, params):
"""Make a GET request to the Magento API."""
client_key = 'Your Client Key'
client_secret = 'Your Client Secret'
resource_owner_key = 'Your Resource Owner Key'
resource_owner_secret = 'Your Resource Owner Secret'
auth = OAuth1(client_key,
client_secret,
resource_owner_key,
resource_owner_secret)
res = requests.get(url=path, params=params, auth=auth)
return res.json()
Upvotes: 1