@@ -131,6 +131,57 @@ used even when this option is enabled.
131131
132132Read more in the [ documentation] [ gmp-usage-attribution ] .
133133
134+ #### ` fetchAppCheckToken ` : () => Promise\< google.maps.MapsAppCheckTokenResult\>
135+
136+ A function that returns a Promise resolving to a Firebase App Check token.
137+ When provided, this function will be set on ` google.maps.Settings.getInstance().fetchAppCheckToken `
138+ after the Google Maps JavaScript API has loaded.
139+
140+ [ Firebase App Check] [ firebase-app-check ] helps protect your Google Maps Platform API key by
141+ blocking traffic from unauthorized sources, preventing malicious requests and
142+ unauthorized API calls that could incur charges. It works by validating that requests
143+ come from legitimate apps using attestation providers like [ reCAPTCHA Enterprise] [ recaptcha-enterprise ] .
144+
145+ ** Example usage with Firebase:**
146+
147+ A custom wrapper component that initializes Firebase App Check and passes
148+ the token fetcher to ` APIProvider ` :
149+
150+ ``` tsx
151+ import React , {PropsWithChildren , useCallback } from ' react' ;
152+ import {APIProvider , APIProviderProps } from ' @vis.gl/react-google-maps' ;
153+ import {initializeApp } from ' firebase/app' ;
154+ import {
155+ getToken ,
156+ initializeAppCheck ,
157+ ReCaptchaEnterpriseProvider
158+ } from ' firebase/app-check' ;
159+
160+ // Firebase and App Check initialization
161+ const app = initializeApp ({/* ... */ });
162+ const appCheck = initializeAppCheck (firebaseApp , {
163+ provider: new ReCaptchaEnterpriseProvider (RECAPTCHA_SITE_KEY ),
164+ isTokenAutoRefreshEnabled: true
165+ });
166+
167+ // custom wrapper for the APIProvider
168+ export function CustomAPIProvider({children , ... props }) {
169+ const fetchAppCheckToken = useCallback (() => getToken (appCheck , false ), []);
170+
171+ return (
172+ <APIProvider { ... props } fetchAppCheckToken = { fetchAppCheckToken } >
173+ { children }
174+ </APIProvider >
175+ );
176+ }
177+ ```
178+
179+ For more information, see:
180+
181+ - [ Using App Check with Maps JavaScript API] [ gmp-app-check ]
182+ - [ Firebase App Check documentation] [ firebase-app-check ]
183+ - [ App Check codelab] [ gmp-app-check-codelab ]
184+
134185### Events
135186
136187#### ` onLoad ` : () => void {#onLoad}
@@ -179,6 +230,10 @@ The following hooks are built to work with the `APIProvider` Component:
179230[ gmp-lang ] : https://developers.google.com/maps/documentation/javascript/localization
180231[ gmp-solutions-usage ] : https://developers.google.com/maps/reporting-and-monitoring/reporting#solutions-usage
181232[ gmp-usage-attribution ] : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.internalUsageAttributionIds
233+ [ gmp-app-check ] : https://developers.google.com/maps/documentation/javascript/maps-app-check
234+ [ gmp-app-check-codelab ] : https://developers.google.com/codelabs/maps-platform/maps-platform-firebase-appcheck
235+ [ firebase-app-check ] : https://firebase.google.com/docs/app-check
236+ [ recaptcha-enterprise ] : https://cloud.google.com/security/products/recaptcha
182237[ api-provider-src ] : https://github.com/visgl/react-google-maps/blob/main/src/components/api-provider.tsx
183238[ rgm-new-issue ] : https://github.com/visgl/react-google-maps/issues/new/choose
184239[ gmp-channel-usage ] : https://developers.google.com/maps/reporting-and-monitoring/reporting#usage-tracking-per-channel
0 commit comments