Skip to content

Commit 312a590

Browse files
authored
refactor(run): use the Cloud Run authentication sample for Cloud Functions (GoogleCloudPlatform#3549)
1 parent ca07e7b commit 312a590

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

run/authentication/src/main/java/com/example/cloudrun/Authentication.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.example.cloudrun;
1818

1919
// [START run_service_to_service_auth]
20+
// [START functions_bearer_token]
2021
import com.google.api.client.http.GenericUrl;
2122
import com.google.api.client.http.HttpRequest;
2223
import com.google.api.client.http.HttpResponse;
@@ -30,9 +31,9 @@
3031

3132
public class Authentication {
3233

33-
// makeGetRequest makes a GET request to the specified Cloud Run endpoint,
34-
// serviceUrl (must be a complete URL), by authenticating with an Id token
35-
// retrieved from Application Default Credentials.
34+
// makeGetRequest makes a GET request to the specified Cloud Run or
35+
// Cloud Functions endpoint, serviceUrl (must be a complete URL), by
36+
// authenticating with an Id token retrieved from Application Default Credentials.
3637
public static HttpResponse makeGetRequest(String serviceUrl) throws IOException {
3738
GoogleCredentials credentials = GoogleCredentials.getApplicationDefault();
3839
if (!(credentials instanceof IdTokenProvider)) {
@@ -51,4 +52,5 @@ public static HttpResponse makeGetRequest(String serviceUrl) throws IOException
5152
return request.execute();
5253
}
5354
}
55+
// [END functions_bearer_token]
5456
// [END run_service_to_service_auth]

0 commit comments

Comments
 (0)