|
21 | 21 | import static java.nio.charset.StandardCharsets.UTF_8; |
22 | 22 |
|
23 | 23 | import com.google.api.client.extensions.appengine.http.UrlFetchTransport; |
24 | | -import com.google.api.client.googleapis.compute.ComputeCredential; |
25 | | -import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; |
26 | 24 | import com.google.api.client.http.HttpRequest; |
27 | 25 | import com.google.api.client.http.HttpRequestInitializer; |
28 | 26 | import com.google.api.client.http.HttpTransport; |
29 | 27 | import com.google.api.client.http.javanet.NetHttpTransport; |
30 | | -import com.google.api.client.json.jackson.JacksonFactory; |
31 | 28 | import com.google.common.collect.Iterables; |
32 | 29 | import com.google.gcloud.spi.ServiceRpcFactory; |
33 | 30 |
|
|
44 | 41 | import java.lang.reflect.Method; |
45 | 42 | import java.net.HttpURLConnection; |
46 | 43 | import java.net.URL; |
47 | | -import java.security.GeneralSecurityException; |
48 | 44 | import java.util.Enumeration; |
49 | 45 | import java.util.Locale; |
50 | 46 | import java.util.Objects; |
@@ -113,24 +109,8 @@ public HttpTransport create() { |
113 | 109 | // Maybe not on App Engine |
114 | 110 | } |
115 | 111 | } |
116 | | - // Consider Compute |
117 | | - try { |
118 | | - return getComputeHttpTransport(); |
119 | | - } catch (Exception e) { |
120 | | - // Maybe not on GCE |
121 | | - } |
122 | 112 | return new NetHttpTransport(); |
123 | 113 | } |
124 | | - |
125 | | - private static HttpTransport getComputeHttpTransport() |
126 | | - throws IOException, GeneralSecurityException { |
127 | | - NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport(); |
128 | | - // Try to connect using Google Compute Engine service account credentials. |
129 | | - ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory()); |
130 | | - // Force token refresh to detect if we are running on Google Compute Engine. |
131 | | - credential.refreshToken(); |
132 | | - return transport; |
133 | | - } |
134 | 114 | } |
135 | 115 |
|
136 | 116 | /** |
|
0 commit comments