Files
skamp/bruno/propify/Authenticate/Auth.bru
Murat Özkorkmaz 9735f1f398 Initial commit with basic CRUD functionality:
* GET all properties
* GET one property by id
* CREATE one property
* DELETE one property by id
2025-08-28 12:57:36 +02:00

49 lines
1.2 KiB
Plaintext

meta {
name: Auth
type: http
seq: 2
}
post {
url: {{KEYCLOAK_BASE_URL}}/realms/propify/protocol/openid-connect/token
body: formUrlEncoded
auth: inherit
}
headers {
Content-Type: application/x-www-form-urlencoded
}
body:form-urlencoded {
grant_type: password
client_id: {{KEYCLOAK_CLIENT_ID}}
username: {{ADMIN_USERNAME}}
password: {{ADMIN_PASSWORD}}
}
script:post-response {
// Parse die JSON-Antwort
const jsonResponse = res.body;
if (jsonResponse.access_token) {
// Schreibe den access_token in eine Umgebungsvariable
// oder in eine collection-Variable
// Option 1: In eine Umgebungsvariable schreiben
// (z.B. für eine bestimmte Umgebung wie "Development")
bru.setEnvVar("BEARER_TOKEN", jsonResponse.access_token);
// Option 2: In eine Collection-Variable schreiben
// (Diese Variable ist global für alle Anfragen in deiner Collection)
// bru.setVar("bearerToken", "Bearer " + jsonResponse.access_token);
} else {
// optional: Error Handling, falls der Token nicht in der Antwort ist
console.log("Error: access_token not found in the response.");
}
}
settings {
encodeUrl: false
}