-
Notifications
You must be signed in to change notification settings - Fork 39
Get user tokens for calling APIs from E2E tests #39
Comments
I also want to migrate away from cypress-keycloak-commands to cypress-keycloak, but the lack of this feature is preventing me from doing so. I assume there are many more people that want to do the same :). @babangsund, is there any intention to add this functionality? Thanks! |
Hi, yeah we have the same requirement and we upgraded to this lib due to the lack of Keycloak >18 support of As a workaround we now use both libs, |
Any news on this? It's been a little while and it'd really come in handy to be able to access the token. |
I do this to get the token: Cypress.Commands.overwrite('login', (originalFn) => {
originalFn({
root: 'test',
realm: 'test',
username: 'test',
password: 'test',
client_id: 'test',
redirect_uri: 'test',
}).then((response) => {
// get authentifaction code from response
const code = '......';
cy.request({
method: 'POST',
url: `${host}/auth/realms/${id}/protocol/openid-connect/token`,
headers: {
'content-type': contentTypeApplication,
},
body: {
code: code,
redirect_uri: baseUrl,
grant_type: 'authorization_code',
client_id: 'client',
},
})
.its('body')
.as('tokens')
.then((tokens) => {
localStorage.setItem('token', tokens.access_token);
localStorage.setItem('refreshToken', tokens.refresh_token);
localStorage.setItem('id_token', tokens.id_token);
});
});
}); |
Is Cypress-Keycloak supporting the ability just to grab the token?
This old Cypress-Keycloak-Commands repo is supporting following:
https://github.com/Fredx87/cypress-keycloak-commands#get-user-tokens-for-calling-apis-from-e2e-tests
The text was updated successfully, but these errors were encountered: