我正在通过提前休息客户端访问Magento网址,并传递一些auth参数,例如:consumer_key,consumer_secret,access token和access secret token。签名方法和随机数是自动的。我希望通过python获得相同的响应。请求类型是GET。如何使用python代码传递这些参数?
答案 0 :(得分:0)
我正在使用Requests library和requests_oauthlib从python访问Magento REST API。
大致沿着这些方向:
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()