File tree Expand file tree Collapse file tree
run/authentication/src/main/java/com/example/cloudrun Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717package com .example .cloudrun ;
1818
1919// [START run_service_to_service_auth]
20+ // [START functions_bearer_token]
2021import com .google .api .client .http .GenericUrl ;
2122import com .google .api .client .http .HttpRequest ;
2223import com .google .api .client .http .HttpResponse ;
3031
3132public 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]
You can’t perform that action at this time.
0 commit comments