When developing or testing the Widget Layout Backend locally, most endpoints require a valid x-rh-identity header. This guide explains how to generate and use this header for local requests.
A helper script is provided at cmd/dev/user-identity.go to generate a valid identity header for local development. You can use the provided Makefile target to generate it easily.
-
Generate the Identity Header Using Makefile
make generate-identity
This will output a long base64-encoded string. This is your identity header value.
-
Copy the Output
Save the output string for use in your API requests.
When using curl, Postman, or any HTTP client, include the header as follows:
curl -H "x-rh-identity: <PASTE_IDENTITY_HEADER_HERE>" http://localhost:PORT/api/widget-layout/v1/widgetsReplace <PASTE_IDENTITY_HEADER_HERE> with the string generated in step 1, and PORT with the port your server is running on (default is usually 8000 or as configured).
- In the Headers tab, add:
- Key:
x-rh-identity - Value: (paste the generated string)
- Key:
If you need a different user or want to reset the identity, you can edit the values in cmd/dev/user-identity.go (e.g., UserID, AccountNumber) and rerun the script using:
make generate-identity- If you receive a
400 Bad Requestwith "Invalid identity header", ensure the header is present and correctly generated. - The backend will reject requests without a valid
x-rh-identityheader.
A valid header will look like:
eyJpZGVudGl0eSI6eyJ1c2VyIjp7IlVzZXJJRCI6InVzZXItMTIzIiwiRmlyc3ROYW1lIjoiSm9obiIsIkxhc3ROYW1lIjoiRG9lIn0sImFjY291bnRfbnVtYmVyIjoiMTIzNDU2Nzg5MCJ9LCJlbnRpdGxlbWVudHMiOnt9fQ==
Summary:
- Use
make generate-identityto generate the header. - Add the output as the
x-rh-identityheader in your requests. - All local API requests must include this header.