googleapis / googleapis/google-api-java-client

Proxy support?

オープン
#1,247 コメント 2 件 リアクション 6 件 担当者 0 名 GitHub で見る
priority: p4 type: feature request
主要言語
Java
スター
1.5k
フォーク
772
平均マージ
1時間 44分
マージ済み PR(30日)
1

説明

I'm using the Firebase Test Lab Java client which uses `google-api-java-client` under the hood. A bug report came in that the API calls aren't respecting proxies. When using the gcloud CLI, proxy support is automatically detected with no end user configuration. Is it possible to achive something similar with `google-api-java-client`?

#### Environment details

- OS: `macOS Mojave 10.14.3`
- Java version: `1.8.0_192`
- google-api-java-client version: `google-api-client-1.28.0.jar`

#### Steps to reproduce

```kotlin
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.googleapis.util.Utils
import com.google.api.services.toolresults.ToolResults
import com.google.auth.http.HttpCredentialsAdapter
import com.google.auth.oauth2.UserCredentials
import java.io.FileInputStream
import java.io.ObjectInputStream
import java.nio.file.Paths

fun main() {
val httpCredential = HttpCredentialsAdapter(ServiceAccountCredentials.getApplicationDefault().createScoped(listOf("https://www.googleapis.com/auth/cloud-platform")))
val httpTransport = GoogleNetHttpTransport.newTrustedTransport()
val jsonFactory = Utils.getDefaultJsonFactory()

val service = ToolResults.Builder(httpTransport, jsonFactory, httpCredential).setApplicationName("test").build()
service.Projects().initializeSettings("1234").execute()
}
```

#### Stacktrace

```
Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:113)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1040)
at com.google.auth.oauth2.UserCredentials.refreshAccessToken(UserCredentials.java:227)
at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:181)
at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:167)
at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)
at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:397)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:515)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:448)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
at DebugKt.main(Debug.kt:22)
at DebugKt.main(Debug.kt)
```

#### External references such as API reference guides used

- https://github.com/TestArmada/flank/issues/527
- https://github.com/googleapis/google-api-java-client/issues/1114

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。