Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused about 'webClientId' and Firebase #1216

Closed
Tobjoern opened this issue Nov 9, 2023 · 1 comment
Closed

Confused about 'webClientId' and Firebase #1216

Tobjoern opened this issue Nov 9, 2023 · 1 comment

Comments

@Tobjoern
Copy link

Tobjoern commented Nov 9, 2023

We are using expo and the google sign in works fine, but I have some question about the way it works exactly.

We set it up, by adding the 'google-services.json' and 'GoogleService-Info.plist' files.
From my understanding these files add the 'Native' Google Oauth Keys to the App, which this library uses.

On Apple it works fine, but for some reason, we need to add the 'webClientId' to the configure call, for it to work on Android.

My question is what the 'webClientId' does exactly? Does it only work on Android or also on iOS? If it works on both, what is the purpose of the 'iosClientId'?

Can we use the 'webClientId' instead of the 'google-services.json'?

Kind regards

@vonovak
Copy link
Member

vonovak commented Dec 31, 2023

Hello and thanks for asking,

We set it up, by adding the 'google-services.json' and 'GoogleService-Info.plist' files.
From my understanding these files add the 'Native' Google Oauth Keys to the App, which this library uses.

they contain the client IDs (web, ios, android) and some more firebase-related stuff. Using these files is not mandatory, because you can provide the IDs as parameters to the module, for example:

    const userInfo = await GoogleOneTapSignIn.signIn({
      webClientId: config.webClientId,
      iosClientId: config.iosClientId,
    });

On Apple it works fine, but for some reason, we need to add the 'webClientId' to the configure call, for it to work on Android.

it'd help to know what exactly the problem is :).

My question is what the 'webClientId' does exactly? Does it only work on Android or also on iOS? If it works on both, what is the purpose of the 'iosClientId'?

The web client ID is usually needed for the ID token, if you want to send it over to your server, for example to create a user account. You will find the web client ID in the "aud" (audience field - identifies the recipients that the JWT is intended for) in the decoded ID token.
It works both on Android and on iOS.

The purpose of iosClientId is to identify your app with Google (in conjunction with bundle identifier). On Android, this is done differently - using the SHA-1 hash of app's signing certificate in conjunction with the package name.

Can we use the 'webClientId' instead of the 'google-services.json'?

google-services.json file is optional so in the scope of google sign in, yes. But you'll have to provide iOS client ID and maybe some other config options too.

Hope this answers the questions, feel free to ask more :)

Thank you 🙂

@vonovak vonovak closed this as completed Dec 31, 2023
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

No branches or pull requests

2 participants