File tree Expand file tree Collapse file tree
packages/firebase_ai/firebase_ai/lib/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -282,19 +282,23 @@ abstract class BaseModel {
282282 ) {
283283 return () async {
284284 Map <String , String > headers = {};
285+
286+ final effectiveAppCheck = appCheck ?? app? .getService <FirebaseAppCheck >();
287+ final effectiveAuth = auth ?? app? .getService <FirebaseAuth >();
288+
285289 // Override the client name in Google AI SDK
286290 headers['x-goog-api-client' ] =
287291 'gl-dart/$packageVersion fire/$packageVersion ' ;
288- if (appCheck != null ) {
292+ if (effectiveAppCheck != null ) {
289293 final appCheckToken = useLimitedUseAppCheckTokens == true
290- ? await appCheck .getLimitedUseToken ()
291- : await appCheck .getToken ();
294+ ? await effectiveAppCheck .getLimitedUseToken ()
295+ : await effectiveAppCheck .getToken ();
292296 if (appCheckToken != null ) {
293297 headers['X-Firebase-AppCheck' ] = appCheckToken;
294298 }
295299 }
296- if (auth != null ) {
297- final idToken = await auth .currentUser? .getIdToken ();
300+ if (effectiveAuth != null ) {
301+ final idToken = await effectiveAuth .currentUser? .getIdToken ();
298302 if (idToken != null ) {
299303 headers['Authorization' ] = 'Firebase $idToken ' ;
300304 }
You can’t perform that action at this time.
0 commit comments