我是空手道新手,想尝试一下。我当前正在开发的 Web 应用程序端点几乎包含所有需要身份验证的端点。
如何在 Karate 中设置 Bearer Token 身份验证类型? 我正在计划使用 VS Code。
请根据您的API请求进行更改:
Feature: Bearer Token Authentication Feature
Background: Hitting the api that will generate token
* url 'https://airportgap.com/api/tokens'
* request {"email": "[email protected]","password": "password"}
* method post
* print 'response is:', response
* def token = response.token
* header Authorization = 'Bearer ' + token
Scenario: Bearer Token Authentication Scenario
Given url 'https://airportgap.com/api/favorites'
When method get
And print 'response is:', response
Then status 200