Skip to content
On this page

Empower Your Test Results with AI-Powered Insights ->

withBearerToken

Specifies bearer authentication.

Syntax

js
withBearerToken(token)
  • token (string) - bearer token.

Usage

โœ… Correct Usage

js
await spec()
  .get('/api/users')
  .withBearerToken('token')
  .expectStatus(200);

Examples

Bearer Authentication

js
const { spec } = require('pactum');

await spec()
  .get('https://httpbin.org/bearer')
  .withBearerToken('my-token')
  .expectStatus(200);

Released under the MIT License.