WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
    • VMware Cloud Foundation 9.1
    • VMware Cloud Foundation 9.0
  • VKS
  • Homelab
    • Hardware Options
    • Hardware Reviews
    • Lab Deployment Scripts
    • Nested Virtualization
    • Homelab Podcasts
  • VMware Nostalgia
  • Apple
You are here: Home / Private AI Services / Configuring OIDC with PKCE in Keycloak for VCF Private AI Services

Configuring OIDC with PKCE in Keycloak for VCF Private AI Services

08.26.2026 by William Lam // Leave a Comment

I have taken a short hiatus from playing with my NVIDIA RTX 4000, which fits perfectly inside a Minisforum MS-A2 and is what I use to run VMware Cloud Foundation (VCF) 9.1. While redeploying my environment to test an upcoming release of VCF Private AI Services (PAIS), I was reminded that the deployment requires an OIDC provider that supports the Authorization Code grant flow with PKCE (Proof Key for Code Exchange).

When I originally deployed PAIS with VCF 9.0, I used Authentik as my identity provider (IdP). With my VCF Infrastructure Services (VIS) Appliance which provides a number of services including Keycloak as an OIDC provider, I wanted to figure out the required Keycloak configuration to satisfy the PAIS OIDC requirements, especially as this can help accelerate Lab/PoC deployments.

After some trial and error, and with the help of OpenAI Codex to debug my live environment, I now have Keycloak successfully configured with PAIS, along with a script to generate the access token required to interact with a PAIS Model Endpoint! 🥳


Step 1 - Log in to the Keycloak Admin UI and switch to the desired realm by navigating to Manage realms.

Step 2 - From the left-hand navigation, select Clients and create a new OIDC client. Provide a Client ID and Name, and optionally enable Always display in UI.


Under Authentication Flow, enable both Standard flow and Direct access grants, with the latter being useful for debugging purposes. Set the PKCE Method to S256.


Set the Valid Redirect URL to the FQDN that you will/have assigned to your PAIS Service configuration (e.g. pais.vcf.lab) and ensure that it includes a trailing slash (e.g. https://pais.vcf.lab/). Add the same FQDN to Web Origins, but without the trailing slash (e.g. https://pais.vcf.lab).


Step 3 - Select the OIDC client that you just created and navigate to the Client Scopes tab. You should see a default dedicated client scope named <name>-dedicated. Select the dedicated client scope, where we will add two mappings, one for groups and another for audience.

Click Add Mapper by Configuration and select Group Membership. Provide a Name, set Token Claim Name to groups, and disable Full group path.


Click Add Mapper by Configuration and select Audience. Provide a Name, select the OIDC client that you created in Step 1 for Included Client Audience, and enable Add to access token.


Step 4 - From the left-hand navigation, select Groups to create your desired group and add users to the group by navigating to Users. For this example, I will assume you have created a group called vcf-admins for demonstration purposes.

At this point, you have successfully created the required OIDC Client with PCKE and this would translate to the following when configuring the IdP for PAIS

auth:
  providers:
  - name: oidc
    oidc:
      authorizedGroups:
      - vcf-admins
      clientId: pais
      groupsClaim: groups
      issuerUrl: https://vis.vcf.lab:9444/realms/VCF
      scope:
      - openid
      - profile
      - offline_access

Note: The issuerUrl can be obtained from Keycloak Admin UI under Realm settings and hover over the OpenID Endpoint Configuration link at the bottom of the page and remove everything after the /.well-known/* string

After successfully deploying a Model Endpoint, you will be provided with an OpenAPI endpoint that you can use to send queries to your deployed AI model. Before connecting to the endpoint, you will need to provide an API key obtained from your IdP, which in our case is Keycloak.

curl -k https://pais.vcf.lab/api/v1/compatibility/openai/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $PAIS_API_KEY" \
  -d '{
        "model": "gpt-oss-20b",
        "prompt": "What is the capital of the United States?",
        "max_tokens": 200,
        "temperature": 0
      }'

Unfortunately, Keycloak does not provide a graphical interface for generating an API token. With help from Google Gemini, I had it create a shell script called validate_keycloak_pkce_api_token_for_pais.sh that performs the PKCE authorization flow to retrieve an authorization code and exchange it for a valid access token that can be used with a PAIS Model Endpoint.

You will need to update the variables at the top of the script with your specific configuration:

  • KEYCLOAK_HOST="https://vis.vcf.lab:9444"
  • REALM="VCF"
  • CLIENT_ID="pais"
  • REDIRECT_URI="https://pais.vcf.lab/"
  • SCOPES="openid profile email"

Run the shell script, which will generate an authorization URL that you can open in a new web browser to begin the authentication flow.


You should be redirected to your IdP, where you will log in with a valid user that belongs to the IdP group you configured in Step 4.


Once authenticated, copy the URL from your browser and paste it back into the shell script, which will exchange the authorization code for an access token that can then be used to authenticate with your PAIS Model Endpoint.


Copy the access_token and set it as the PAIS_API_TOKEN environment variable. You should now be able to successfully connect to your PAIS Model Endpoint and retrieve a response from your deployed AI model.

Categories // Private AI Services, VMware Cloud Foundation Tags // PAIS, VCF 9.1

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Configuring OIDC with PKCE in Keycloak for VCF Private AI Services 08/26/2026
  • VCF 9.1 - Understanding VCF Converge & Import Scenarios for vCenter Server Without NSX 08/24/2026
  • VCF 9.1 - Configuring Harbor to use VCF Identity Broker (IDB) for External Identity Federation 08/19/2026
  • Quick Tip: The Fastest Way to Clear Partitions for ESX Reinstallation 08/15/2026
  • Quick Tip: Reducing High CPU Utilization in VCF Automation (VCFA) on AMD Zen4/Zen5 CPUs 08/12/2026
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.

To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2026

Loading Comments...