Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.13k stars 341 forks source link

Error getting access token for service account: Connection reset #926

Closed liuhen1001 closed 3 years ago

liuhen1001 commented 3 years ago

Failed while running ./gradlew bootstrap, Can anyone tell me the reason, this problem has bothered me for a long time. Here is the running log:

Task :Camera:bootstrapRelease Downloading listings Downloading app details Downloading release notes Downloading in-app products Task :Camera:bootstrapRelease FAILED 1 actionable task: 1 executed FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':Camera:bootstrapRelease'. Multiple task action failures occurred: A failure occurred while executing com.github.triplet.gradle.play.tasks.Bootstrap$DetailsDownloader Error getting access token for service account: Connection reset A failure occurred while executing com.github.triplet.gradle.play.tasks.Bootstrap$ListingsDownloader Error getting access token for service account: Connection reset A failure occurred while executing com.github.triplet.gradle.play.tasks.Bootstrap$ReleaseNotesDownloader Error getting access token for service account: Connection reset A failure occurred while executing com.github.triplet.gradle.play.tasks.Bootstrap$ProductsDownloader Error getting access token for service account: Connection reset

SUPERCILEX commented 3 years ago

Does this always happen? Otherwise (if it's intermittent), your WiFi is probably bad.

Also, what version are you using? It could be that the API you're using is too old and is being rejected.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

liuhen1001 commented 3 years ago

Hi, this problem occurs every time when I run the program

The version is: implementation 'com.github.triplet.gradle:play-publisher:3.4.0-SNAPSHOT'

SUPERCILEX commented 3 years ago

Honestly there's not much I can do. Since it happens every time, maybe you have a firewall policy blocking the connection? You can also run a gradle command with --debug which might help by showing you the exact request and response. (Search in the logs for androidpublisher.googleapis.com.)

liuhen1001 commented 3 years ago

I try to run this command with debug, and then I saw detailed exception information, can you please see and give me some help?

2021-04-07T16:10:27.288+0800 [INFO] [com.google.api.client.http.HttpTransport] curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.38.0 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://oauth2.googleapis.com/token' << $$$ 2021-04-07T16:10:28.282+0800 [WARN] [com.google.api.client.http.HttpTransport] exception thrown while executing request java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.read(InputRecord.java:503) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1340) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1315) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264) 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:1012) at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:441) at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:160) at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:147) at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:91) at com.github.triplet.gradle.androidpublisher.internal.AndroidPublisherAdapter.initialize(AndroidPublisher.kt:82) at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:88) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:404) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565) at com.github.triplet.gradle.androidpublisher.internal.DefaultPlayPublisher.insertEdit(DefaultPlayPublisher.kt:33) at com.github.triplet.gradle.play.tasks.internal.PlayApiService.getOrCreateEditId(PlayApiService.kt:70) at com.github.triplet.gradle.play.tasks.internal.PlayApiService.access$getOrCreateEditId(PlayApiService.kt:20) at com.github.triplet.gradle.play.tasks.internal.PlayApiService$edits$2.invoke(PlayApiService.kt:29) at com.github.triplet.gradle.play.tasks.internal.PlayApiService$edits$2.invoke(PlayApiService.kt:20) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.github.triplet.gradle.play.tasks.internal.PlayApiService.getEdits(PlayApiService.kt) at com.github.triplet.gradle.play.tasks.Bootstrap$DetailsDownloader.execute(Bootstrap.kt:88) at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67) at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63) at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97) at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195) at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75) at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62) at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76) at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76) at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60) at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.lang.Thread.run(Thread.java:748) 2021-04-07T16:10:28.283+0800 [INFO] [com.google.api.client.http.HttpTransport] -------------- REQUEST -------------- POST https://oauth2.googleapis.com/token Accept-Encoding: gzip User-Agent: Google-HTTP-Java-Client/1.38.0 (gzip) Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Content-Length: 812

SUPERCILEX commented 3 years ago

Yeah, I don't see anything specific. Maybe reboot your router or something? I can't think of how this would be related to GPP unfortunately.

liuhen1001 commented 3 years ago

Anyway, thank you very much for your help, I will try to solve this problem in other ways.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

harshmandan commented 2 years ago

@SUPERCILEX I'm facing the same issue.

Execution failed for task ':app:publishFlavourCAMReleaseBundle'.
> A failure occurred while executing com.github.triplet.gradle.play.tasks.PublishBundle$Processor
   > There was a failure while executing work items
      > A failure occurred while executing com.github.triplet.gradle.play.tasks.PublishBundle$BundleUploader
         > Error getting access token for service account: Connection reset, iss: devtest@neon-mesh-300003.iam.gserviceaccount.com
harshmandan commented 2 years ago

I tried creating new service accounts to see if that was the problem but the result remains the same.

harshmandan commented 2 years ago

Here's a --debug log:

2022-02-14T16:52:53.201+0530 [INFO] [com.google.api.client.http.HttpTransport] curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.39.2 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://oauth2.googleapis.com/token' << $$$
2022-02-14T16:53:05.648+0530 [WARN] [com.google.api.client.http.HttpTransport] exception thrown while executing request
javax.net.ssl.SSLException: Connection reset
        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:127)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:369)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:312)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:307)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:144)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1488)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1394)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:441)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:412)
        at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
        at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)        
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1375)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1350)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:220)
        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:1012)
        at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:609)
        at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:243)
        at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:240)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)
        at com.google.auth.oauth2.OAuth2Credentials$AsyncRefreshResult.executeIfNew(OAuth2Credentials.java:567)
        at com.google.auth.oauth2.OAuth2Credentials.asyncFetch(OAuth2Credentials.java:206)
        at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:156)
        at com.google.auth.oauth2.ServiceAccountCredentials.getRequestMetadata(ServiceAccountCredentials.java:962)
        at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)
        at com.github.triplet.gradle.androidpublisher.internal.AndroidPublisherAdapter.initialize(AndroidPublisher.kt:89)
        at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:91)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:404)        
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
        at com.github.triplet.gradle.androidpublisher.internal.DefaultPlayPublisher.insertEdit(DefaultPlayPublisher.kt:34)
        at com.github.triplet.gradle.play.tasks.internal.PlayApiService.getOrCreateEditId(PlayApiService.kt:79)
        at com.github.triplet.gradle.play.tasks.internal.PlayApiService.access$getOrCreateEditId(PlayApiService.kt:21)
        at com.github.triplet.gradle.play.tasks.internal.PlayApiService$edits$2.invoke(PlayApiService.kt:30)
        at com.github.triplet.gradle.play.tasks.internal.PlayApiService$edits$2.invoke(PlayApiService.kt:21)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.github.triplet.gradle.play.tasks.internal.PlayApiService.getEdits(PlayApiService.kt)
        at com.github.triplet.gradle.play.tasks.PublishBundle$BundleUploader.upload(PublishBundle.kt:101)
        at com.github.triplet.gradle.play.tasks.internal.workers.PublishArtifactWorkerBase.execute(PublishArtifactWorkerBase.kt:15)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)      
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)   
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)       
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:832)
        Suppressed: java.net.SocketException: Connection reset by peer
                at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420)
                at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440)
                at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826)
                at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1051)
                at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:82)
                at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:400)
                ... 72 more
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:323)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:981)
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
        at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:110)
        ... 69 more
SUPERCILEX commented 2 years ago

You could try running that curl command (hit Ctrl + D to start it) to get more details on why the connection is being reset. GPP isn't doing anything special here, so it's either something with your network or Google's servers.