Я довольно новичок в этой области, и я изо всех сил пытаюсь выполнить успешное GET с моего flask сервера. Мой сервер работает в docker на виртуальной машине Ubuntu 18.04 Server, а моей хост-системой является Ubuntu 19.10.
Я не знаю, какая информация вам нужна, чтобы помочь мне. Я получил файл YAML, из которого я сгенерировал свой API. Сначала в нескольких строках из моего YAML-файла я сгенерировал все из:
servers:
- url: /v1
paths:
/supported_types:
get:
operationId: getSupportedTypes
summary: Retrieve supported types
responses:
200:
description: OK
content:
application/json:
schema:
type: object
properties:
username:
type: boolean
email_address:
type: boolean
И моего раздела безопасности:
security:
- APIKey: []
components:
securitySchemes:
APIKey:
type: apiKey
in: header
name: Authorization
В моем коде я не сильно изменился, поэтому мой authentic_controller. py выглядит следующим образом:
def check_APIKey(api_key, required_scopes):
return {'test_key': 'test_value'}
В моем default_controller.py есть этот метод, который я предполагаю указанным методом GET:
def get_supported_types(): # noqa: E501
"""Retrieve supported types
# noqa: E501
:rtype: InlineResponse200
"""
notes = {username:true, email_address:true}
return notes
Поэтому, когда я запускаю curl -H 'X-Api-Key: DEMO_KEY' --trace-ascii /tmp/dump.txt http://127.0.0.1:3080/v1/supported_types
I получить этот вывод через консоль:
{
"detail": "No authorization token provided",
"status": 401,
"title": "Unauthorized",
"type": "about:blank"
}
А в файле dump.txt написано:
== Info: Trying 127.0.0.1:3080...
== Info: TCP_NODELAY set
== Info: Connected to 127.0.0.1 (127.0.0.1) port 3080 (#0)
=> Send header, 120 bytes (0x78)
0000: GET /v1/supported_types HTTP/1.1
0025: Host: 127.0.0.1:3080
003b: User-Agent: curl/7.65.3
0054: Accept: */*
0061: X-Api-Key: DEMO_KEY
0076:
== Info: Mark bundle as not supporting multiuse
== Info: HTTP 1.0, assume close after body
<= Recv header, 27 bytes (0x1b)
0000: HTTP/1.0 401 UNAUTHORIZED
<= Recv header, 40 bytes (0x28)
0000: Content-Type: application/problem+json
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 119
<= Recv header, 39 bytes (0x27)
0000: Server: Werkzeug/0.16.0 Python/3.6.10
<= Recv header, 37 bytes (0x25)
0000: Date: Sun, 16 Feb 2020 14:17:22 GMT
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 119 bytes (0x77)
0000: {. "detail": "No authorization token provided",. "status": 401
0040: ,. "title": "Unauthorized",. "type": "about:blank".}.
== Info: Closing connection 0
Я почти уверен, что что-то действительно отсутствует, но, возможно, кто-то может скажите мне, что это такое (и, возможно, объясните, что я могу неправильно понять.