简体   繁体   English

BadParametersError:使用OVH Python包装器时签名无效

[英]BadParametersError: Invalid signature when using OVH Python wrapper

I'm using OVH API along with python wrapper: 我正在使用OVH API和python包装器:

https://pypi.python.org/pypi/ovh https://pypi.python.org/pypi/ovh

When trying to execute this code: 尝试执行此代码时:

import ovh

client = ovh.Client()

# Print nice welcome message
print "Welcome", client.get('/me')['firstname']

I get this error: 我收到此错误:

Traceback (most recent call last):
  File "index.py", line 6, in <module>
    print "Welcome", client.get('/me')['firstname']
  File "/home/rubinhozzz/.local/lib/python2.7/site-packages/ovh/client.py", line 290, in get
    return self.call('GET', _target, None, _need_auth)
  File "/home/rubinhozzz/.local/lib/python2.7/site-packages/ovh/client.py", line 419, in call
    raise BadParametersError(json_result.get('message'))
ovh.exceptions.BadParametersError: Invalid signature

My info is saved in the ovh.conf as the documentation suggests. 正如文档所示,我的信息保存在ovh.conf中。

[default]
; general configuration: default endpoint
endpoint=ovh-eu

[ovh-eu]
application_key=XXXlVy5SE7dY7Gc5
application_secret=XXXdTEBKHweS5F0P0tb0lfOa8GoQPy4l
consumer_key=pscg79fXXX8ESMIXXX7dR9ckpDR7Pful

It looks that I can connect but when trying to use the services like for instance "/me", the error raises! 它看起来我可以连接但是当试图使用像“/ me”这样的服务时,错误就会引发!

It is difficult to reproduce the issue because it requires an application key and it seems that it is only granted to existing customers of OVH. 很难重现这个问题,因为它需要一个应用程序密钥,而且它似乎只授予OVH的现有客户。 I couldn't even see a link to an account registration page on their site. 我甚至看不到他们网站上的帐户注册页面的链接。

By looking at the code of the call() method in /ovh/client.py , it seems that their server doesn't recognise the format or the content off the signature sent by your script. 通过查看/ovh/client.py中call()方法代码 ,他们的服务器似乎无法识别脚本发送的签名的格式或内容。 According to the inline documentation the signature is generated from these parameters: 根据内联文档,签名是从这些参数生成的:

  • application_secret application_secret
  • consumer_key CONSUMER_KEY
  • METHOD 方法
  • full request url 完整的请求网址
  • body 身体
  • server current time (takes time delta into account) 服务器当前时间(考虑时间delta)

Since your call is identical to the example code provided on the OVH Python package web page, the last four parameters should be valid. 由于您的调用与OVH Python包网页上提供的示例代码相同,因此最后四个参数应该有效。 In that case it looks like either the application secret or the customer key (or both) in your config file are not correct. 在这种情况下,配置文件中的应用程序密钥客户密钥 (或两者)看起来都不正确。

See also the documentation on OVH site under the 'Signing requests' heading. 另请参阅“签名请求”标题下的OVH站点上文档 They explain how the signature is made and what it should look like. 他们解释了如何制作签名以及它应该是什么样子。

Perhaps try to re-create a new application API to obtain new key and secret and make sure you copy them without any additional character. 也许尝试重新创建一个新的应用程序API来获取新的密钥和秘密,并确保您复制它们没有任何额外的字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM