0
我很努力地获得OAuth2授权,以处理我在EC2 Linux服务器实例(运行Ubuntu 13.04)上运行它时处理的脚本。有关片段是:为什么OAuth2身份验证在家庭计算机上工作,但不在服务器上工作?
with open('creds.txt') as f:
creds = {}
for line in f:
creds[line.split(',')[0]] = line.split(',')[1].rstrip('\n')
self.client_id = creds['client_id']
self.client_secret = creds['client_secret']
self.username = creds['username']
self.password = creds['password'])
token_response = requests.post(
"https://example.com/oauth2/access_token/",
data={
"grant_type": "password",
"client_id": self.client_id,
"client_secret": self.client_secret,
"username": self.username,
"password": self.password,
"scope": "read+write"}).json()
它运行我家的电脑(运行Windows 7)的罚款,只是没有当我尝试远程运行它,我得到:{u'error': u'invalid_client'}
。
我试过设置一个新的客户端ID和密码,仍然得到相同的响应。
- 为什么它在远程服务器上对我自己的机器有不同的作用?
-
这对创建应用程序的机器有影响吗(请参阅评论)?- 我通过在两种环境中使用CURL
成功验证来消除了这种可能性。
我现在唯一能想到的是,可能请求库在Ubuntu上处理POST请求的方式不同。有谁知道这是否是这种情况?
[This answer](http://stackoverflow.com/a/11267728/1706564)似乎可能相关,因为它表明客户端ID关心它生成的操作系统。尽管如此,我无法在[文档](http://tools.ietf.org/html/rfc6749)中找到任何证据。 –