Skip to content

Commit 5030531

Browse files
committed
fix(proxy): credetials
1 parent fba0e9e commit 5030531

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

Diff for: github-action/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/vacxe/google-play-cli:0.4.7
1+
FROM ghcr.io/vacxe/google-play-cli:0.4.8
22

33
COPY entrypoint.sh /entrypoint.sh
44
COPY templates /templates

Diff for: src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreApi.kt

+5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package com.github.vacxe.googleplaycli
22

33
import com.github.vacxe.googleplaycli.actions.*
44
import com.github.vacxe.googleplaycli.environments.Env
5+
import com.github.vacxe.googleplaycli.environments.SystemProxy
56
import com.google.api.client.http.HttpRequestInitializer
67
import com.google.api.client.json.gson.GsonFactory
78
import com.google.api.services.androidpublisher.AndroidPublisher
89
import com.google.api.services.androidpublisher.AndroidPublisherScopes
910
import com.google.auth.http.HttpCredentialsAdapter
1011
import com.google.auth.oauth2.ServiceAccountCredentials
1112
import java.io.InputStream
13+
import java.net.Authenticator
14+
import java.net.PasswordAuthentication
1215
import java.time.Duration
1316

1417

@@ -32,6 +35,8 @@ class PlayStoreApi(serviceAccountInputStream: InputStream, appName: String) :
3235
override val androidPublisher: AndroidPublisher
3336

3437
init {
38+
SystemProxy.apply()
39+
3540
val accountCredentials = ServiceAccountCredentials
3641
.fromStream(serviceAccountInputStream)
3742
.createScoped(listOf(AndroidPublisherScopes.ANDROIDPUBLISHER))

Diff for: src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fun main(args: Array<String>) {
8686
addCmd {
8787
object : CliktCommand(name = "version", help = "Library version code") {
8888
override fun run() {
89-
println("0.4.7")
89+
println("0.4.8")
9090
}
9191
}
9292
}

Diff for: src/main/kotlin/com/github/vacxe/googleplaycli/TransportFactory.kt

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import org.apache.http.impl.conn.DefaultProxyRoutePlanner
1717
import java.io.FileInputStream
1818
import java.security.KeyStore
1919

20-
2120
object TransportFactory {
2221
private val host = Env.Proxy.host
2322
private val port = Env.Proxy.port
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.github.vacxe.googleplaycli.environments
2+
3+
import java.net.Authenticator
4+
import java.net.PasswordAuthentication
5+
6+
object SystemProxy {
7+
private val host = Env.Proxy.host
8+
private val port = Env.Proxy.port
9+
private val username = Env.Proxy.username
10+
private val password = Env.Proxy.password
11+
12+
fun apply() {
13+
if(host != null && port != null) {
14+
System.setProperty("proxyEnabled", "true")
15+
System.setProperty("proxyHost", host)
16+
System.setProperty("proxyPort", port)
17+
18+
if(username != null && password != null) {
19+
Authenticator.setDefault(
20+
object : Authenticator() {
21+
override fun getPasswordAuthentication(): PasswordAuthentication =
22+
PasswordAuthentication(username, password.toCharArray())
23+
}
24+
)
25+
26+
System.setProperty("proxyUser", username)
27+
System.setProperty("proxyPassword", password)
28+
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "")
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)