您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

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

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

import oauth2 as oauth
import time
import urllib2 as urllib

echo_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>jdoe17@echo360.com</email-address><block-alerts>false</block-alerts><time-zone>US/Eastern</time-zone><locale>en_US</locale><credentials><user-name>jdoe17@echo360.com</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
python 2022/1/1 18:37:37 有416人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶