Skip to content

Commit d879ee1

Browse files
authored
refactor: GoogleCredential to GoogleCredentials (#36)
1 parent 368b821 commit d879ee1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

config/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ run {
2323

2424
dependencies {
2525
testCompile group: 'junit', name: 'junit', version: '4.12'
26-
compile 'com.google.api-client:google-api-client:1.22.0'
27-
compile 'com.google.code.gson:gson:2.7'
26+
compile 'com.google.auth:google-auth-library-oauth2-http:0.26.0'
27+
compile 'com.google.code.gson:gson:2.8.7'
2828
}

config/src/main/java/com/google/firebase/samples/config/Configure.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packagecom.google.firebase.samples.config;
22

3-
importcom.google.api.client.googleapis.auth.oauth2.GoogleCredential;
3+
importcom.google.auth.oauth2.GoogleCredentials;
44
importcom.google.gson.Gson;
55
importcom.google.gson.GsonBuilder;
66
importcom.google.gson.JsonElement;
@@ -18,7 +18,6 @@
1818
importjava.net.HttpURLConnection;
1919
importjava.net.URL;
2020
importjava.util.Arrays;
21-
importjava.util.Collections;
2221
importjava.util.Scanner;
2322
importjava.util.zip.GZIPInputStream;
2423
importjava.util.zip.GZIPOutputStream;
@@ -42,11 +41,11 @@ public class Configure {
4241
*/
4342
// [START retrieve_access_token]
4443
privatestaticStringgetAccessToken() throwsIOException {
45-
GoogleCredentialgoogleCredential = GoogleCredential
46-
.fromStream(newFileInputStream("service-account.json"))
47-
.createScoped(Arrays.asList(SCOPES));
48-
googleCredential.refreshToken();
49-
returngoogleCredential.getAccessToken();
44+
GoogleCredentialsgoogleCredentials = GoogleCredentials
45+
.fromStream(newFileInputStream("service-account.json"))
46+
.createScoped(Arrays.asList(SCOPES));
47+
googleCredentials.refreshAccessToken();
48+
returngoogleCredentials.getAccessToken().getTokenValue();
5049
}
5150
// [END retrieve_access_token]
5251

@@ -276,4 +275,4 @@ public static void main(String[] args) throws IOException {
276275
}
277276
}
278277

279-
}
278+
}

0 commit comments

Comments
 (0)
close