@@ -77,6 +77,8 @@ public class FirebaseInstallationServiceClient {
77
77
78
78
private static final String X_ANDROID_IID_MIGRATION_KEY = "x-goog-fis-android-iid-migration-auth" ;
79
79
80
+ private static final String API_KEY_HEADER = "x-goog-api-key" ;
81
+
80
82
private static final int NETWORK_TIMEOUT_MILLIS = 10000 ;
81
83
82
84
private static final Pattern EXPIRATION_TIMESTAMP_PATTERN = Pattern .compile ("[0-9]+s" );
@@ -133,13 +135,12 @@ public InstallationResponse createFirebaseInstallation(
133
135
URL url =
134
136
new URL (
135
137
String .format (
136
- "https://%s/%s/%s?key=%s " ,
138
+ "https://%s/%s/%s" ,
137
139
FIREBASE_INSTALLATIONS_API_DOMAIN ,
138
140
FIREBASE_INSTALLATIONS_API_VERSION ,
139
- resourceName ,
140
- apiKey ));
141
+ resourceName ));
141
142
while (retryCount <= MAX_RETRIES ) {
142
- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
143
+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
143
144
144
145
try {
145
146
httpURLConnection .setRequestMethod ("POST" );
@@ -249,15 +250,14 @@ public void deleteFirebaseInstallation(
249
250
URL url =
250
251
new URL (
251
252
String .format (
252
- "https://%s/%s/%s?key=%s " ,
253
+ "https://%s/%s/%s" ,
253
254
FIREBASE_INSTALLATIONS_API_DOMAIN ,
254
255
FIREBASE_INSTALLATIONS_API_VERSION ,
255
- resourceName ,
256
- apiKey ));
256
+ resourceName ));
257
257
258
258
int retryCount = 0 ;
259
259
while (retryCount <= MAX_RETRIES ) {
260
- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
260
+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
261
261
httpURLConnection .setRequestMethod ("DELETE" );
262
262
httpURLConnection .addRequestProperty ("Authorization" , "FIS_v2 " + refreshToken );
263
263
@@ -310,13 +310,12 @@ public TokenResult generateAuthToken(
310
310
URL url =
311
311
new URL (
312
312
String .format (
313
- "https://%s/%s/%s?key=%s " ,
313
+ "https://%s/%s/%s" ,
314
314
FIREBASE_INSTALLATIONS_API_DOMAIN ,
315
315
FIREBASE_INSTALLATIONS_API_VERSION ,
316
- resourceName ,
317
- apiKey ));
316
+ resourceName ));
318
317
while (retryCount <= MAX_RETRIES ) {
319
- HttpURLConnection httpURLConnection = openHttpURLConnection (url );
318
+ HttpURLConnection httpURLConnection = openHttpURLConnection (url , apiKey );
320
319
try {
321
320
httpURLConnection .setRequestMethod ("POST" );
322
321
httpURLConnection .addRequestProperty ("Authorization" , "FIS_v2 " + refreshToken );
@@ -346,7 +345,7 @@ public TokenResult generateAuthToken(
346
345
throw new IOException ();
347
346
}
348
347
349
- private HttpURLConnection openHttpURLConnection (URL url ) throws IOException {
348
+ private HttpURLConnection openHttpURLConnection (URL url , String apiKey ) throws IOException {
350
349
HttpURLConnection httpURLConnection = (HttpURLConnection ) url .openConnection ();
351
350
httpURLConnection .setConnectTimeout (NETWORK_TIMEOUT_MILLIS );
352
351
httpURLConnection .setReadTimeout (NETWORK_TIMEOUT_MILLIS );
@@ -363,6 +362,7 @@ private HttpURLConnection openHttpURLConnection(URL url) throws IOException {
363
362
}
364
363
}
365
364
httpURLConnection .addRequestProperty (X_ANDROID_CERT_HEADER_KEY , getFingerprintHashForPackage ());
365
+ httpURLConnection .addRequestProperty (API_KEY_HEADER , apiKey );
366
366
return httpURLConnection ;
367
367
}
368
368
0 commit comments