You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Giving you a feedback on your request to simplify/centralize provider configuration, the solution that we have found was to expose platform specific configuration through optional environment variables - both for Google and Apple. This way, for those that do not want to set them directly on the code, it is possible to pass them during build using the --dart-define option.
As an example, for the Google Sign-In we exposed the variables GOOGLE_CLIENT_ID and GOOGLE_SERVER_CLIENT_ID. If clientId and serverClientId values are not supplied when initializing the service on the code below, the provider will try to fetch them from the environment variables.
/// If [clientId] and [serverClientId] are not provided, will try to load the
/// values from `GOOGLE_CLIENT_ID` and `GOOGLE_SERVER_CLIENT_ID` environment
/// variables, respectively. If the values are not provided by any means, an
/// error will be thrown by the underlying [GoogleSignIn].
///
/// The parameters [nonce] and [hostedDomain] are optional and will be passed
/// directly to the [GoogleSignIn] initialize method. See the documentation
/// of [GoogleSignIn.initialize] for more details.
Future<void> initializeGoogleSignIn({
String? clientId,
String? serverClientId,
String? nonce,
String? hostedDomain,
}) async {
To run the app on Android, for example, you can do:
flutter run \
-d "<android_device>" \
--dart-define="GOOGLE_CLIENT_ID=<android_client_id>.apps.googleusercontent.com" \
--dart-define="GOOGLE_SERVER_CLIENT_ID=<web_client_id>.apps.googleusercontent.com"
It is on the user to manage such environment variables and define which value to use for each platform, but no boilerplate is necessary on the code to forward platform specific configuration.
Do you think this approach is enough for the kind of experience you were expecting?
Thanks for getting back to me. This looks like a very good approach. Using optional environment variables keeps things flexible without adding extra code, and it fits well with how we manage platform-specific values during our builds. This solves the issue I had in mind.
Activity
Floris29 commentedon Jun 30, 2025
@tp Will the integration of Google and Apple auth be diffrent?
24 remaining items
tooManyexceptions in account registration and password reset flows #4114marcelomendoncasoares commentedon Nov 14, 2025
Hi @Floris29!
Giving you a feedback on your request to simplify/centralize provider configuration, the solution that we have found was to expose platform specific configuration through optional environment variables - both for Google and Apple. This way, for those that do not want to set them directly on the code, it is possible to pass them during build using the
--dart-defineoption.As an example, for the Google Sign-In we exposed the variables
GOOGLE_CLIENT_IDandGOOGLE_SERVER_CLIENT_ID. IfclientIdandserverClientIdvalues are not supplied when initializing the service on the code below, the provider will try to fetch them from the environment variables.serverpod/modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/google/google_sign_in_service.dart
Lines 120 to 133 in a9f4715
To run the app on Android, for example, you can do:
It is on the user to manage such environment variables and define which value to use for each platform, but no boilerplate is necessary on the code to forward platform specific configuration.
Do you think this approach is enough for the kind of experience you were expecting?
Floris29 commentedon Nov 14, 2025
Hi @marcelomendoncasoares ,
Thanks for getting back to me. This looks like a very good approach. Using optional environment variables keeps things flexible without adding extra code, and it fits well with how we manage platform-specific values during our builds. This solves the issue I had in mind.
Thanks for taking the time to explain it!