如何在python中使用两足式oauth2发送POST?

如何在python中使用两足式oauth2发送POST?,第1张

如何在python中使用两足式oauth2发送POST?

这是我如何使POST或PUT正常工作的实际工作代码,由Echo360 Lecture Capture的Wes
Barnes提供。我不希望其他人做2腿oauth POST / PUT来重新发明轮子。

import oauth2 as oauthimport timeimport urllib2 as urllibecho_base_url = 'http://pilot.echo360.com/ess/scheduleapi/v1'consumer = oauth.Consumer(key ='xxxxx', secret='xxxx')client = oauth.Client(consumer)params = "<person><first-name>Jon</first-name><last-name>Doe</last-name><title>Super  Hero</title><email-address>[email protected]</email-address><block-alerts>false</block-alerts><time-zone>US/Eastern</time-zone><locale>en_US</locale><credentials><user-name>[email protected]</user-name><password>password</password></credentials><organization-roles><organization-role><organization-id>b1973c39-dc76-4cab-a4aa-3f9efd628df2</organization-id><role>role-name-admin</role></organization-role></organization-roles></person>"resp, content = client.request(     echo_base_url + "/people/",     method = "PUT",     body=params,     headers={'Content-type': 'application/xml'}     #force_auth_header=True     )print resp, content


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5654834.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存