che icon indicating copy to clipboard operation
che copied to clipboard

How to use Che REST API with Authorization token?

Open lthomas122 opened this issue 10 months ago • 2 comments

Summary

Problem

I'm struggling to interact with the REST API. Every endpoint redirects me to the Che sign in page.

Steps Taken

Get the JWT from keycloak:

curl --location 'https://keycloak.<che_url>/realms/che/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<client_id> \
--data-urlencode 'client_secret=<client_secret>' \
--data-urlencode 'scope=openid email profile' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=<username>' \
--data-urlencode 'password=<password>' \
--data-urlencode 'redirect_uri=https://<che_url>/oauth/callback'

Then use the token on an API endpoint:

curl --location 'https://<che_url>/api/user/id' \
--header 'Authorization: Bearer <jwt_token>' \

I've tried the whole jwt, the id_token and the access_token, but every time the request redirects me to the Che login page

Relevant information

Che is deployed on AWS EKS using Kubernetes

lthomas122 avatar Mar 07 '25 13:03 lthomas122

@tolusha @olexii4 folks, please take a look

akurinnoy avatar Mar 07 '25 15:03 akurinnoy

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

che-bot avatar Nov 13 '25 08:11 che-bot