gnodet opened a new pull request, #30501: URL: https://github.com/apache/camel/pull/30501
## Summary Remove the erroneous `.setServiceAccountScopes(scopes)` call from `createOAuthCredential()` in `GoogleCredentialsHelper`. This one-line deletion fixes OAuth login for all Google components when scopes are set, and in particular for `google-calendar-stream` whose configuration always supplies scopes. ## Root Cause `GoogleCredential.Builder.setServiceAccountScopes()` is intended exclusively for service account credentials that carry a private key. `GoogleCredential`'s constructor enforces this: if `serviceAccountScopes` is non-null, `serviceAccountPrivateKey` must also be non-null. When OAuth credentials (clientId + clientSecret + tokens) were used, no private key was present, so the constructor threw `IllegalArgumentException`. `GoogleCalendarStreamConfiguration` defaults `scopes` to `CalendarScopes.CALENDAR`, meaning every OAuth login attempt via `google-calendar-stream` triggered this exception. Other Google components (`mail`, `sheets`, `drive`, `calendar`) failed the same way whenever the user set scopes with OAuth credentials. ## Fix - Remove `.setServiceAccountScopes(scopes)` from the `GoogleCredential.Builder` chain in `createOAuthCredential()`. For OAuth credentials, scopes are granted at consent time (when the refresh token was obtained) and are not passed when building or refreshing the credential. - Remove the now-unused `scopes` parameter from the private `createOAuthCredential()` method signature. - Update the Javadoc to explain why scopes are intentionally not set here. ## Tests Three regression tests added to `GoogleCredentialsHelperTest`: - `testOAuthCredentialWithScopesDoesNotThrow` — OAuth with a single scope (calendar); was `IllegalArgumentException` before the fix. - `testOAuthCredentialWithMultipleScopesDoesNotThrow` — OAuth with multiple scopes (calendar + gmail + drive); mirrors `google-calendar-stream`'s default scopes scenario. - `testOAuthCredentialWithNullScopesDoesNotThrow` — OAuth with null scopes; verifies the pre-existing no-scopes path continues to work. All 8 tests in `GoogleCredentialsHelperTest` pass. The two new regression tests reproduce the `IllegalArgumentException` on the unfixed code (verified by temporarily reverting the fix). Fixes https://issues.apache.org/jira/browse/CAMEL-27187 --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
