添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am working with Python2.7 and I need to access a certain API (Nuagen): https://nuagenetworks.github.io/vsd-api-documentation/usage.html

In the documentation, they say the following:

Getting the API key. To obtain and API key, the first step is to make a /me API call. This API call returns information about the account being used.

    GET /me HTTP/1.1
    X-Nuage-Organization: my company
    Content-Type: application/json
    Authorization: $AUTHORIZATION_STRING
  

The authorization string for the /me API MUST be formatted like the following:

    $AUTHORIZATION_STRING = Basic base64($LOGIN:$PASSWORD)

So I try to build my requests in the folowing way;

import requests
url = 'https://an.ip.add.ress:8443/nuage/api/v4_0/me'
user = 'myuser'
passw = 'mypass'
cps = 'myorganization'
headers = {
    "Authorization": "Basic d29jdTpjdXdv",
    "Cache-Control": "no-cache",
    "Content-Type": "application/json",
    "X-Nuage-Organization": "csp",
response = requests.get(url, auth=(user, passw), headers=headers)
# Also tried with:
# response = requests.get(url, headers=headers)

However, I'm always getting this error:

requests.exceptions.SSLError: bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)

Any idea on how to access this API with Python requests? Or any other way?

I really don't know. Is there any way I could find out? But I can access the server via web browser and browse through its pages. – Xar Oct 4, 2017 at 9:34

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.