@@ -77,6 +77,8 @@ public class FirebaseInstallationServiceClient {
7777
7878 private static final String X_ANDROID_IID_MIGRATION_KEY = "x-goog-fis-android-iid-migration-auth" ;
7979
80+ private static final String API_KEY_HEADER = "x-goog-api-key" ;
81+
8082 private static final int NETWORK_TIMEOUT_MILLIS = 10000 ;
8183
8284 private static final Pattern EXPIRATION_TIMESTAMP_PATTERN = Pattern .compile ("[0-9]+s" );
@@ -133,13 +135,12 @@ public InstallationResponse createFirebaseInstallation(
133135 URL url =
134136 new URL (
135137 String .format (
136- "https://%s/%s/%s?key=%s " ,
138+ "https://%s/%s/%s" ,
137139 FIREBASE_INSTALLATIONS_API_DOMAIN ,
138140 FIREBASE_INSTALLATIONS_API_VERSION ,
139- resourceName ,
140- apiKey ));
141+ resourceName ));
141142 while (retryCount <= MAX_RETRIES ) {
142- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
143+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
143144
144145 try {
145146 httpURLConnection .setRequestMethod ("POST" );
@@ -249,15 +250,14 @@ public void deleteFirebaseInstallation(
249250 URL url =
250251 new URL (
251252 String .format (
252- "https://%s/%s/%s?key=%s " ,
253+ "https://%s/%s/%s" ,
253254 FIREBASE_INSTALLATIONS_API_DOMAIN ,
254255 FIREBASE_INSTALLATIONS_API_VERSION ,
255- resourceName ,
256- apiKey ));
256+ resourceName ));
257257
258258 int retryCount = 0 ;
259259 while (retryCount <= MAX_RETRIES ) {
260- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
260+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
261261 httpURLConnection .setRequestMethod ("DELETE" );
262262 httpURLConnection .addRequestProperty ("Authorization" , "FIS_v2 " + refreshToken );
263263
@@ -310,13 +310,12 @@ public TokenResult generateAuthToken(
310310 URL url =
311311 new URL (
312312 String .format (
313- "https://%s/%s/%s?key=%s " ,
313+ "https://%s/%s/%s" ,
314314 FIREBASE_INSTALLATIONS_API_DOMAIN ,
315315 FIREBASE_INSTALLATIONS_API_VERSION ,
316- resourceName ,
317- apiKey ));
316+ resourceName ));
318317 while (retryCount <= MAX_RETRIES ) {
319- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
318+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
320319 try {
321320 httpURLConnection .setRequestMethod ("POST" );
322321 httpURLConnection .addRequestProperty ("Authorization" , "FIS_v2 " + refreshToken );
@@ -346,7 +345,7 @@ public TokenResult generateAuthToken(
346345 throw new IOException ();
347346 }
348347
349- private HttpURLConnection openHttpURLConnection (URL url ) throws IOException {
348+ private HttpURLConnection openHttpURLConnection (URL url , String apiKey ) throws IOException {
350349 HttpURLConnection httpURLConnection = (HttpURLConnection ) url .openConnection ();
351350 httpURLConnection .setConnectTimeout (NETWORK_TIMEOUT_MILLIS );
352351 httpURLConnection .setReadTimeout (NETWORK_TIMEOUT_MILLIS );
@@ -363,6 +362,7 @@ private HttpURLConnection openHttpURLConnection(URL url) throws IOException {
363362 }
364363 }
365364 httpURLConnection .addRequestProperty (X_ANDROID_CERT_HEADER_KEY , getFingerprintHashForPackage ());
365+ httpURLConnection .addRequestProperty (API_KEY_HEADER , apiKey );
366366 return httpURLConnection ;
367367 }
368368
0 commit comments