Skip to content

Commit

Permalink
fix(proxy): credetials
Browse files Browse the repository at this point in the history
  • Loading branch information
Vacxe committed May 31, 2024
1 parent fba0e9e commit 5030531
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion github-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/vacxe/google-play-cli:0.4.7
FROM ghcr.io/vacxe/google-play-cli:0.4.8

COPY entrypoint.sh /entrypoint.sh
COPY templates /templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package com.github.vacxe.googleplaycli

import com.github.vacxe.googleplaycli.actions.*
import com.github.vacxe.googleplaycli.environments.Env
import com.github.vacxe.googleplaycli.environments.SystemProxy
import com.google.api.client.http.HttpRequestInitializer
import com.google.api.client.json.gson.GsonFactory
import com.google.api.services.androidpublisher.AndroidPublisher
import com.google.api.services.androidpublisher.AndroidPublisherScopes
import com.google.auth.http.HttpCredentialsAdapter
import com.google.auth.oauth2.ServiceAccountCredentials
import java.io.InputStream
import java.net.Authenticator
import java.net.PasswordAuthentication
import java.time.Duration


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

init {
SystemProxy.apply()

val accountCredentials = ServiceAccountCredentials
.fromStream(serviceAccountInputStream)
.createScoped(listOf(AndroidPublisherScopes.ANDROIDPUBLISHER))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun main(args: Array<String>) {
addCmd {
object : CliktCommand(name = "version", help = "Library version code") {
override fun run() {
println("0.4.7")
println("0.4.8")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.apache.http.impl.conn.DefaultProxyRoutePlanner
import java.io.FileInputStream
import java.security.KeyStore


object TransportFactory {
private val host = Env.Proxy.host
private val port = Env.Proxy.port
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.vacxe.googleplaycli.environments

import java.net.Authenticator
import java.net.PasswordAuthentication

object SystemProxy {
private val host = Env.Proxy.host
private val port = Env.Proxy.port
private val username = Env.Proxy.username
private val password = Env.Proxy.password

fun apply() {
if(host != null && port != null) {
System.setProperty("proxyEnabled", "true")
System.setProperty("proxyHost", host)
System.setProperty("proxyPort", port)

if(username != null && password != null) {
Authenticator.setDefault(
object : Authenticator() {
override fun getPasswordAuthentication(): PasswordAuthentication =
PasswordAuthentication(username, password.toCharArray())
}
)

System.setProperty("proxyUser", username)
System.setProperty("proxyPassword", password)
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "")
}
}
}
}

0 comments on commit 5030531

Please sign in to comment.