playwright-zephyr icon indicating copy to clipboard operation
playwright-zephyr copied to clipboard

Problem with Bearer token

Open cislapi opened this issue 1 year ago • 1 comments

It is not possible to login using bearer token.

The token type is always BASIC https://github.com/elaichenkov/playwright-zephyr/blob/main/src/zephyr.service.ts#L40

    this.password = options.password!;
    let tokenType = 'Basic'
    if (this.authorizationToken ){
      tokenType = 'Bearer     //  <------ Bearer if authorizationToken
   }
    this.basicAuthToken = Buffer.from(`${this.user}:${this.password}`).toString('base64');
    this.authorizationToken = options.authorizationToken ?? this.basicAuthToken;
    this.projectKey = options.projectKey;

    this.axios = axios.create({
      baseURL: this.url,
      headers: {
        'Content-Type': 'application/json',
        Authorization: `${tokenType} ${this.authorizationToken}`,   <---------------
      },

cislapi avatar Dec 05 '23 06:12 cislapi

Hey, The Basic token is only for the Zephyr Server version. If you are using Cloud version, then you need to use cloud reporter. For instance:

// playwright.config.ts
const config: PlaywrightTestConfig = {
  reporter: [
    ['playwright-zephyr/lib/src/cloud', { // <-- Reporter for the Zephyr Scale cloud version
      projectKey: 'JARV', // <-- Replace with your project key
      authorizationToken: process.env.ZEPHYR_AUTH_TOKEN, // <-- Replace with your authorization token
    }],
  ],
}

elaichenkov avatar Dec 05 '23 12:12 elaichenkov