I have a login endpoint /api/v1.2/Login
upon sending a post request with the payload
{
"organisation": "organisation123",
"username": "username123",
"password": "password123"
}
I get a response like
{
"access_token": "12345",
"token_type": "bearer",
"expires_in": 14400,
"refresh_token": ""
}
Now every authorized request to the API requires the Authorization
header to be set with the value Bearer 12345
I want to, in Playwright, be able to login and store the access_token
and then set the Authorization
header for every subsequent request.
test('foo', async ({ page }) => {
await page.request.post('/testendpoint'); // this post request should now have Authorization header set
});
How can I achieve this?