From 20515a6a51011d1d42391f9f1111c372688c5594 Mon Sep 17 00:00:00 2001 From: Arthur Thompson Date: Wed, 23 May 2018 08:09:27 -0700 Subject: [PATCH 1/2] Show possible use of multiple scopes --- .../java/com/google/firebase/samples/config/Configure.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/src/main/java/com/google/firebase/samples/config/Configure.java b/config/src/main/java/com/google/firebase/samples/config/Configure.java index 09663e5..4ec2b21 100644 --- a/config/src/main/java/com/google/firebase/samples/config/Configure.java +++ b/config/src/main/java/com/google/firebase/samples/config/Configure.java @@ -15,6 +15,7 @@ import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; +import java.util.Arrays; import java.util.Collections; import java.util.Scanner; import java.util.zip.GZIPInputStream; @@ -28,7 +29,7 @@ public class Configure { private final static String PROJECT_ID = ""; private final static String BASE_URL = "https://firebaseremoteconfig.googleapis.com"; private final static String REMOTE_CONFIG_ENDPOINT = "/v1/projects/" + PROJECT_ID + "/remoteConfig"; - private final static String REMOTE_CONFIG_SCOPE = "https://www.googleapis.com/auth/firebase.remoteconfig"; + private final static String[] SCOPES = { "https://www.googleapis.com/auth/firebase.remoteconfig" }; /** * Retrieve a valid access token that can be use to authorize requests to the Remote Config REST @@ -40,7 +41,7 @@ public class Configure { private static String getAccessToken() throws IOException { GoogleCredential googleCredential = GoogleCredential .fromStream(new FileInputStream("service-account.json")) - .createScoped(Collections.singleton(REMOTE_CONFIG_SCOPE)); + .createScoped(Arrays.asList(SCOPES)); googleCredential.refreshToken(); return googleCredential.getAccessToken(); } From c432b133b5f514550e23cd68082b74f88266b9f1 Mon Sep 17 00:00:00 2001 From: Arthur Thompson Date: Wed, 23 May 2018 08:18:22 -0700 Subject: [PATCH 2/2] Add include tags --- .../main/java/com/google/firebase/samples/config/Configure.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/src/main/java/com/google/firebase/samples/config/Configure.java b/config/src/main/java/com/google/firebase/samples/config/Configure.java index 4ec2b21..f22f36b 100644 --- a/config/src/main/java/com/google/firebase/samples/config/Configure.java +++ b/config/src/main/java/com/google/firebase/samples/config/Configure.java @@ -38,6 +38,7 @@ public class Configure { * @return Access token. * @throws IOException */ + // [START retrieve_access_token] private static String getAccessToken() throws IOException { GoogleCredential googleCredential = GoogleCredential .fromStream(new FileInputStream("service-account.json")) @@ -45,6 +46,7 @@ private static String getAccessToken() throws IOException { googleCredential.refreshToken(); return googleCredential.getAccessToken(); } + // [END retrieve_access_token] /** * Get current Firebase Remote Config template from server and store it locally.