flat-rose-38795
07/29/2025, 12:23 PMgoogle_sign_in
Flutter package. This uses Android's native Google login capabilities, which keeps the user inside the app (ideal UX).
For identity management, I'm using ORY Kratos to handle registration and login flows via its API.
My current understanding of the flow is:
• The user signs in with Google using the native google_sign_in package.
• I receive an ID token on the device.
• I then call my backend to verify the token, and from there, either register or log the user in via Kratos (likely using the admin API).
What I Want to Achieve
• I want to avoid building a full custom backend flow to handle Google sign-in, token verification, and Kratos user management.
• Ideally, I’d like to leverage Kratos's built-in OIDC capabilities to handle this.
• I want to enable account linking, meaning users can sign up with email/password and later link their Google account (or vice versa).
• I want to keep Kratos as the source of truth for identity, without duplicating identity logic outside it.
My Question
Is there a supported or recommended way to use Kratos's OIDC provider logic in this native scenario — where I already have an ID token from Google on the device — without writing a custom backend that manually verifies the ID token and uses Kratos’s admin API?
Or is a custom backend component currently the only way to bridge native Google Sign-In with Kratos?
Thanks in advance for any insights or suggestions on best practices for this setup!brief-egg-61061
07/29/2025, 12:23 PMbrief-egg-61061
07/29/2025, 12:23 PMclient_id
as your native app. If your Android app uses different audiences (e.g., debug/release), you can specify them in the additional_id_token_audiences
field in the Kratos provider config. This ensures Kratos will accept ID tokens issued for your app’s audience, not just the web client ID [see official guidance](https://www.ory.sh/docs/kratos/social-signin/google#using-the-google-sdk-on-native-apps) and [discussion](https://github.com/ory/kratos/discussions/4223). 2. Obtain the ID token on the device using the google_sign_in
Flutter package. 3. Submit the ID token directly to Kratos as part of the self-service registration or login flow. You do this by calling the appropriate Kratos endpoint (e.g., updateRegistrationFlow
or updateLoginFlow
) and passing the ID token (and optionally a nonce) in the payload. Kratos will then: - Validate the ID token using Google’s public keys. - Create or update the user identity as needed. - Issue a session if configured. Example (from the docs, using Flutter): dart var body = UpdateRegistrationFlowWithOidcMethod( (b) => b ..idToken = idToken ..method = 'oidc' ..provider = 'google', ); ory.getFrontendApi().updateRegistrationFlow( flow: flowId, updateRegistrationFlowBody: UpdateRegistrationFlowBody( (b) => b..oneOf = OneOf.fromValue1(value: body)), );
[See full example and explanation](https://www.ory.sh/docs/kratos/social-signin/google#using-the-google-sdk-on-native-apps) 4. Account linking is supported: If you enable the oidc
method in the settings flow, users can link or unlink their Google account to an existing Kratos identity (e.g., one created with email/password). This is handled by Kratos’s self-service settings flow, not by your backend. See [linking/unlinking documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#link-and-unlink-from-google-facebook-github--openid-connect--oauth-20). Summary: You do not need a custom backend for this scenario. Kratos is designed to accept and validate ID tokens from native Google sign-in flows directly, as long as you configure the provider correctly. All identity logic and account linking can remain in Kratos, keeping it as your source of truth. If you need to support multiple Google client IDs (e.g., for web, iOS, Android), you can use the additional_id_token_audiences
config option to allow Kratos to accept tokens for all your app variants, so you don’t need to define multiple providers for each platform [see discussion](https://github.com/ory/kratos/discussions/4223). References: - [Google SDK on native apps with Kratos](https://www.ory.sh/docs/kratos/social-signin/google#using-the-google-sdk-on-native-apps) - [OIDC provider configuration for multiple audiences](https://github.com/ory/kratos/discussions/4223) - [Account linking in Kratos](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#link-and-unlink-from-google-facebook-github--openid-connect--oauth-20)