3

基本的な認証で保護された API がありますが、認証資格情報を入力した後、要求ヘッダーに適用されません。swaggerエディターで「ERROR Server not found or an error occurred」、フィドラーで「401 Unauthorized」と表示されました。

ユーザー名とパスワード: odata と qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=

ここに私の闊歩jsonがあります

{
"swagger": "2.0",
"info": {
    "version": "1.0.0",
    "title": "Basic Auth Example",
    "description": "An example for how to use Basic Auth with Swagger.\nServer code is available [here](http://navm3.cloudapp.net:90/nav/odata). It's running on NAVM3.\n\n**You can use below User Name and Password for test.**\n* User Name: `ODATA`\n* Password: `qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=`\n"
},
"host": "navm3.cloudapp.net:90",
"basePath": "/nav/odata",
"schemes": [
    "http"
],
"securityDefinitions": {
    "basicAuth": {
        "type": "basic",
        "description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
    }
},
"paths": {
    "/": {
        "get": {
            "security": [
                {
                    "basicAuth": []
                }
            ],
            "responses": {
                "200": {
                    "description": "Will send `Authenticated` if authentication is succesful, otherwise it will send `Unauthorized`"
                }
            }
        }
    }
}

}

ここに画像の説明を入力

ここに画像の説明を入力

4

2 に答える 2

0

次の部分を交換してみてください。

"securityDefinitions": {
    "basicAuth": {
        "type": "basic",
        "description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
    }
},

以下で

"securityDefinitions": {
    "basicAuth": {
        "type": "http",
        "scheme": "basic"
    }
},

残りはここにあるように参照してください https://swagger.io/docs/specification/authentication/basic-authentication/

于 2021-12-15T09:44:02.073 に答える