Is it possible to send a request to the REST API from the browser?
It’s only for development purposes. I’m trying to implement an “impersonate” button to quickly switch between different user types.
I’m using the JS adapter, doing the following as a test:
let id = 'e023a554-1274-46c5-af32-73eead4779'
let token = keycloak.token
axios
.post(
`${__OIDC_URL__}/admin/realms/dev/users/${id}/impersonation`,
{
realm: 'dev',
user: id,
},
{
headers: {
Authorization: `Bearer ${token}`,
},
}
)
.then((data) => {
console.log(data)
})
.catch((err) => {
console.log(err)
})
I thought it would be as easy as giving my current user the “impersonate” role from the realm-management client but that didn’t work. I get 403 Forbidden.
I feel like I’m missing something obvious here. Or maybe it’s not possible.
Thanks