File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/main/java/com/google/firebase/quickstart Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 2222dependencies {
2323 testCompile group : ' junit' , name : ' junit' , version : ' 4.12'
2424
25- compile ' com.google.api-client :google-api-client:1.22 .0'
26- compile ' com.google.code.gson:gson:2.8.1 '
25+ compile ' com.google.auth :google-auth-library-oauth2-http:0.26 .0'
26+ compile ' com.google.code.gson:gson:2.8.7 '
2727}
Original file line number Diff line number Diff line change 11package com .google .firebase .quickstart ;
22
33import com .google .api .client .googleapis .auth .oauth2 .GoogleCredential ;
4+ import com .google .auth .oauth2 .GoogleCredentials ;
45import com .google .gson .Gson ;
56import com .google .gson .GsonBuilder ;
67import com .google .gson .JsonObject ;
@@ -43,11 +44,11 @@ public class Messaging {
4344 */
4445 // [START retrieve_access_token]
4546 private static String getAccessToken () throws IOException {
46- GoogleCredential googleCredential = GoogleCredential
47- .fromStream (new FileInputStream ("service-account.json" ))
48- .createScoped (Arrays .asList (SCOPES ));
49- googleCredential . refreshToken ();
50- return googleCredential .getAccessToken ();
47+ GoogleCredentials googleCredentials = GoogleCredentials
48+ .fromStream (new FileInputStream ("service-account.json" ))
49+ .createScoped (Arrays .asList (SCOPES ));
50+ googleCredentials . refreshAccessToken ();
51+ return googleCredentials .getAccessToken (). getTokenValue ();
5152 }
5253 // [END retrieve_access_token]
5354
You can’t perform that action at this time.
0 commit comments