{"id":20144980,"url":"https://github.com/michalswi/keycloak-client","last_synced_at":"2026-05-10T08:49:24.398Z","repository":{"id":57708955,"uuid":"244361765","full_name":"michalswi/keycloak-client","owner":"michalswi","description":"simple keycloak client","archived":false,"fork":false,"pushed_at":"2020-08-04T14:41:39.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-13T10:51:15.160Z","etag":null,"topics":["keycloak","keycloak-client","oidc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michalswi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-02T12:08:40.000Z","updated_at":"2023-09-23T04:34:53.000Z","dependencies_parsed_at":"2022-09-26T21:20:45.769Z","dependency_job_id":null,"html_url":"https://github.com/michalswi/keycloak-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalswi%2Fkeycloak-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalswi%2Fkeycloak-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalswi%2Fkeycloak-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalswi%2Fkeycloak-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michalswi","download_url":"https://codeload.github.com/michalswi/keycloak-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587858,"owners_count":19986628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keycloak","keycloak-client","oidc"],"created_at":"2024-11-13T22:13:10.841Z","updated_at":"2026-05-10T08:49:19.353Z","avatar_url":"https://github.com/michalswi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple keycloak oidc client \n\nThe OIDC plugin needs three parameters to hook up with Keycloak (defined in `main.go`): \n\n- the client ID (clientID)\n- the client secret (clientSecret)\n- the discovery endpoint (keycloakURL)  \n\nThe discovery endpoint is needed to get information on where it can do authentication, token introspection, etc.\n\nAn example how to use Golang Keycloak Client (not OIDC) described in the [bottom](#-play-with-golang-keycloak-client). It's base on:  \nhttps://github.com/Nerzal/gocloak\n\n#### # run Keycloak\n\n```\n$ mkdir -p /tmp/kc\n$ docker run -d --rm --name kc \\\n-p 8080:8080 \\\n-e KEYCLOAK_USER=admin \\\n-e KEYCLOAK_PASSWORD=admin \\\n-v /tmp/kc:/tmp \\\njboss/keycloak:10.0.2\n```\n\n#### # configure Keycloak\n```\n- create a realm named 'demo'\n\n- create a client named 'demo-client' with 'openid-connect' (it's by default)\n\n- configure the 'demo-client' to be confidential (Settings \u003e\u003e 'Access Type' to 'confidential') \nand use 'http://localhost:5050/demo/callback' as a 'Valid Redirect URIs'\n\n- create a user 'demo' with password 'demo'. Make sure to activate and 'impersonate' for this user (set new password)\n\n- check access, log in to 'http://localhost:8080/auth/realms/demo/account/'\n\n- log in to 'http://localhost:8080/auth/' and get client secret (Clients \u003e\u003e demo-client \u003e\u003e Credentials \u003e\u003e Secret)\n```\n\n#### # play with oidc\n```\n#1 \n# run keycloak oidc client\n\n$ SECRET=91da3bca-f4a0-4ead-baad-bc26e0b4298d\n$ go run main.go $SECRET\n\n# in a web browser connect to 'localhost:5050/home'\n# it will redirect you to Keycloak\n# provide 'demo/demo', it will redirect you to '/home'\n\n\n#2 \n# run POC app\n\n$ SECRET=91da3bca-f4a0-4ead-baad-bc26e0b4298d\n$ go run POC-go/gokey.go $SECRET\n\n# in web browser connect to 'localhost:5050/demo'\n# it will redirect you to Keycloak\n# provide demo/demo, it will give you token\n\n$ ACCESS_TOKEN=\u003c\u003e\n$ curl -i -XGET -H \"Authorization: Bearer $ACCESS_TOKEN\" localhost:5050/demo\n```\n\n#### # play with Golang Keycloak Client\n\n```\nAdd to configured Keycloak:\n\n- new realm role 'demo-role'\n\n- enable 'Service Accounts Enabled' for 'demo-client', once it's enabled new 'Service Account User' will be created (not visible in the Keycloak UI) with the name 'service-account-demo-client'\n\n$ go run goclient/kclient.go\ndemo-client, 360e32f1-c0d4-4fb6-9179-2e70f5dfbb04\nservice-account-demo-client, 712cb93e-a091-4013-b3da-b9c84148d476\ndemo-role, b3735f63-1391-402d-a5f6-cb8b032dd84e\nRealm role 'demo-role' added to user 'service-account-demo-client'\n\n- once realm role is added, check in the Keycloak GUI (can't get that thru API for kc version \u003c= 11.0.0), \nClients \u003e\u003e select 'demo-client' \u003e\u003e Service Account Roles \u003e\u003e Realm Roles\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalswi%2Fkeycloak-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichalswi%2Fkeycloak-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalswi%2Fkeycloak-client/lists"}