के साथ ओथ अनुरोध कैसे भेजें I outh के साथ प्रमाणीकृत अनुरोध कैसे भेजना है, यह जानने के लिए दीवार के खिलाफ मेरा सिर तेज़ कर रहा है।python-oauth2
मैं टोकन तक पहुंचने में सक्षम था, लेकिन पूरी तरह से यह सुनिश्चित नहीं था कि उनके साथ अनुरोध कैसे सबमिट किया जाए। मैं चहचहाना के डेवलपर की सूचना के आधार पर यह पाया:
https://dev.twitter.com/docs/auth/oauth/single-user-with-examples#python जो एक अधिकृत अनुरोध भेजने के लिए कुछ उदाहरण कोड है:
:,def oauth_req(url, key, secret, http_method="GET", post_body=None,http_headers=None):
consumer = oauth.Consumer(key=consumerKey, secret=consumerSecret)
token = oauth.Token(key=tokenKey, secret=tokenSecret)
client = oauth.Client(consumer, token)
resp, content = client.request(
url,
method=http_method,
body=post_body,
headers=http_headers,
#force_auth_header=True
)
return resp,content
oauth_req('http://openapi.etsy.com/v2/shops/:user/transactions',tokenKey,tokenSecret)
हालांकि जब मैं अपने जानकारी के सभी शामिल है, मैं निम्न त्रुटि प्राप्त
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/python-22060Umg.py", line 153, in <module>
transactions = oauth_req('http://openapi.etsy.com/v2/shops/:user/transactions',tokenKey,tokenSecret)
File "/tmp/python-22060Umg.py", line 76, in oauth_req
force_auth_header=True
TypeError: request() got an unexpected keyword argument 'force_auth_header'
जहां: उपयोगकर्ता वास्तविक उपयोगकर्ता है (मैंने इसे पोस्ट से हटा दिया है) और टोकनकी/टोकनसेक्रेट एक्सेस टोकन हैं।
मैं शायद सोचा था कि यह हमलावर लाइन बाहर टिप्पणी के रूप में सरल था, लेकिन ऐसी कोई भाग्य:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/python-22060hwm.py", line 153, in <module>
transactions = oauth_req('http://openapi.etsy.com/v2/shops/:user/transactions',tokenKey,tokenSecret)
File "/tmp/python-22060hwm.py", line 75, in oauth_req
headers=http_headers
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 662, in request
req.sign_request(self.method, self.consumer, self.token)
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 493, in sign_request
self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
TypeError: must be string or buffer, not None
तो अब, stackoverflow, तुम मेरे ही उम्मीद कर रहे हैं! अनुरोध सबमिट करने के लिए मेरे एक्सेस टोकन का उपयोग करने के लिए किसी के पास सुझाव हैं?
धन्यवाद!
क्या आप अपना कोड पोस्ट कर सकते हैं? इसके बिना मदद करने के लिए वास्तव में संभव नहीं है – jterrace
कोड मूल पोस्ट में लिंक के समान है। मैंने मूल पोस्ट को कोड रखने के लिए संपादित किया है; धन्यवाद! –