From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4251: OAuth implementation
Date: Wed, 09 Sep 2026 15:45:37 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4251-rc3970363369@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4251@github.com>
References: <gh-pgjdbc-pgjdbc-4251@github.com>
(on testkit/src/main/java/org/postgresql/test/OAuthTestTokenProvider.java)
Three things in this method, and they matter more than usual because this class is the only worked example of `OAuthTokenProvider` in the repository.
`oauthToken system property not set` on line 48 describes something the method does not do. This branch runs when Keycloak returned a response with an empty `access_token`.
Line 58 puts `request.getClientSecret()` into the resource owner's `password` field. `realm.json` declares `pgjdbc-test` as `publicClient: true`, so it has no client secret at all, and `testoidc-password` is the password of user `testoauth`. The example therefore teaches that `oauthClientSecret` carries a user password, and `getClientSecret()` is never exercised as what it is.
`readResponse` reads only `getInputStream()`. On a 4xx the JVM throws there and the Keycloak error body in `getErrorStream()` is lost, so a broken realm shows up as `Failed to get OAuth token: Server returned HTTP response code: 401` with nothing to act on.
One design note: `getToken` makes a full HTTP round trip per connection with no caching. Under `authMode=oauth` that is one request per connection for the whole suite, and a single network hiccup fails an unrelated test.