Skip to content

Pass webClientId parameter to ios serverClientId config#24

Open
OrkhanAlikhanov wants to merge 1 commit intosbaiahmed1:mainfrom
OrkhanAlikhanov:patch-2
Open

Pass webClientId parameter to ios serverClientId config#24
OrkhanAlikhanov wants to merge 1 commit intosbaiahmed1:mainfrom
OrkhanAlikhanov:patch-2

Conversation

@OrkhanAlikhanov
Copy link
Copy Markdown

@OrkhanAlikhanov OrkhanAlikhanov commented Apr 19, 2026

Closes #23

Consequences of this PR? Not sure

Summary by CodeRabbit

  • New Features

    • Enhanced Google Sign-In configuration with support for optional web client ID parameters, enabling more flexible authentication setup.
  • Improvements

    • Minor formatting corrections to configuration handling.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

The change adds support for passing an optional webClientId parameter through the Google Sign-In configuration flow, enabling it to be set as the serverClientID in GIDConfiguration for proper audience validation in ID tokens.

Changes

Cohort / File(s) Summary
iOS Google Sign-In Configuration
ios/GoogleAuth.swift
Added webClientId parameter reading and forwarding to createGoogleSignInConfiguration. Updated GIDConfiguration initialization to set serverClientID from webClientId. Minor formatting corrections applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through Swift so fine,
Passing IDs down the line,
webClientId finds its place,
In the server's audience embrace!
Now tokens sing with proper sound,
Security's gained, all around! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: passing the webClientId parameter to iOS serverClientId configuration.
Linked Issues check ✅ Passed The code changes directly address issue #23 by reading webClientId from params and passing it to GIDConfiguration as serverClientID, fulfilling the requirement.
Out of Scope Changes check ✅ Passed All changes are scoped to the webClientId-to-serverClientID configuration mapping in GoogleAuth.swift with minor formatting fixes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ios/GoogleAuth.swift`:
- Around line 40-41: Normalize webClientId before passing it to
createGoogleSignInConfiguration: trim whitespace and if the resulting string is
empty, set webClientId to nil so a blank/whitespace-only value is not forwarded
as serverClientID to GIDConfiguration; update the code around the webClientId
extraction and the call to createGoogleSignInConfiguration (and any parameter
named serverClientID inside that function) to use the trimmed-or-nil value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4af00d0c-ef52-47f0-9bb1-51c06e14b7aa

📥 Commits

Reviewing files that changed from the base of the PR and between 3f5a6c8 and 0f41e6c.

📒 Files selected for processing (1)
  • ios/GoogleAuth.swift

Comment thread ios/GoogleAuth.swift
Comment on lines +40 to +41
let webClientId = params["webClientId"] as? String
let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Inspect webClientId extraction, validation, and serverClientID forwarding.
# Expected: webClientId should be normalized and/or validated before reaching GIDConfiguration.
rg -n -C3 'webClientId|serverClientID|isValidClientIdFormat|validateConfiguration' ios/GoogleAuth.swift

Repository: sbaiahmed1/react-native-google-auth

Length of output: 2862


Normalize webClientId before forwarding it as serverClientID.

Currently, webClientId is extracted without trimming or validation. A blank or whitespace-only value will be passed as a non-nil serverClientID to GIDConfiguration, silently misconfiguring the ID-token audience. Normalize blank values to nil by trimming whitespace and treating empty strings as absent, similar to the validation applied to iosClientId elsewhere in the function.

🛡️ Suggested normalization
-            let webClientId = params["webClientId"] as? String
-            let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
+            let rawWebClientId = (params["webClientId"] as? String)?
+                .trimmingCharacters(in: .whitespacesAndNewlines)
+            let webClientId = rawWebClientId?.isEmpty == false ? rawWebClientId : nil
+            let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let webClientId = params["webClientId"] as? String
let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
let rawWebClientId = (params["webClientId"] as? String)?
.trimmingCharacters(in: .whitespacesAndNewlines)
let webClientId = rawWebClientId?.isEmpty == false ? rawWebClientId : nil
let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ios/GoogleAuth.swift` around lines 40 - 41, Normalize webClientId before
passing it to createGoogleSignInConfiguration: trim whitespace and if the
resulting string is empty, set webClientId to nil so a blank/whitespace-only
value is not forwarded as serverClientID to GIDConfiguration; update the code
around the webClientId extraction and the call to
createGoogleSignInConfiguration (and any parameter named serverClientID inside
that function) to use the trimmed-or-nil value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: webClientId should be passed down to serverClientId

1 participant