Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storageState coming empty when authenticating via API #4

Open
arturotg-r opened this issue Nov 22, 2023 · 0 comments
Open

storageState coming empty when authenticating via API #4

arturotg-r opened this issue Nov 22, 2023 · 0 comments
Assignees
Labels
help wanted Extra attention is needed pending question Further information is requested

Comments

@arturotg-r
Copy link

🐞 Describe the question:

Hello! Hope you are doing well! I've been stuck with the API authentication exercise. I'm using the demoqa.com site so I might be ignoring something.

This is what I have:

import { test as setup, type Page, chromium } from '@playwright/test';

const authFile = '.auth/api-admin.json';

setup('authenticate', async ({ request }) => {
  
  // Send authentication request. Replace with your own.
  await request.post('https://demoqa.com/Account/v1/GenerateToken', {
    form: {
      "email":"tau-admin",
      "password":"TestingWithR3n@t@"}
    });
  
  await request.storageState({ path: authFile });
});

This will pass and I get a 200 response, but for some reason, there's no cookies info in the json file. This is the resulting json file

{ "cookies": [], "origins": [] }

Checking the tracing I don't see any cookies in the response.

I already tried with the different APIs that are available in the Swagger doc, but I'm getting the same result. The APIs I tried are:
https://demoqa.com/Account/v1/Authorized
https://demoqa.com/Account/v1/GenerateToken
https://demoqa.com/Account/v1/Login

My guess is that I have to use the generated token, but not sure how to accomplish this or if this is the right approach.

Hope that you can help 😅 and thanks in advance!

🎡 A picture of your pet or a toy or something really cool:
image

@arturotg-r arturotg-r added help wanted Extra attention is needed pending question Further information is requested labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed pending question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants