fastlane/fastlane

Google Api Error: Unauthorized - Request is missing required authentication credential when trying to do a Google Play release

denissb opened this issue · 37 comments

New Issue Checklist

Issue Description

We have a problem that started 2 days ago with publishing Google Play releases.
When running the release_playstore lane that use supply Google APIs return Google Api Error: Unauthorized - Request is missing required authentication credential.
We have checked the service account key and it is valid and does not have an expiry date. Can someone experienced take a look at this problem. The assumption is Google made changes to the way API requests need to be done.

Command executed
lane :release_playstore do
  identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
  supply(
     package_name: identifier,
     metadata_path: "fastlane/metadata/android/#{identifier}",
)
end
Complete output when running fastlane, including the stack trace and command used
| release_status                     | completed                                                          |
| track                              | beta                                                               |
| json_key                           | /home/vsts/work/_temp/fastlane-serviceaccount.json                 |
| aab                                | /home/vsts/work/1/xxx-Android-Production/xxx-release.aab |
| skip_upload_apk                    | false                                                              |
| skip_upload_aab                    | false                                                              |
| skip_upload_metadata               | false                                                              |
| skip_upload_changelogs             | false                                                              |
| skip_upload_images                 | false                                                              |
| skip_upload_screenshots            | false                                                              |
| track_promote_release_status       | completed                                                          |
| validate_only                      | false                                                              |
| check_superseded_tracks            | false                                                              |
| timeout                            | 300                                                                |
| deactivate_on_promote              | true                                                               |
| changes_not_sent_for_review        | false                                                              |
| rescue_changes_not_sent_for_review | true                                                               |
| ack_bundle_installation_warning    | false                                                              |
+------------------------------------+--------------------------------------------------------------------+

[09:28:36]: Preparing aab at path '/home/vsts/work/1/golive-Android-Production/xxx-release.aab' for upload...
[09:29:02]: Updating track 'beta'...
[09:29:03]: Preparing to upload for language 'de-DE'...
[09:29:04]: Updating changelog for '14551' and language 'de-DE' to default changelog...
[09:29:04]: Preparing to upload for language 'en-US'...
[09:29:04]: Uploading image file fastlane/metadata/android/xxx/en-US/images/featureGraphic.png...
[09:29:07]: Uploading image file fastlane/metadata/android/xxx/en-US/images/icon.png...
[09:29:10]: Uploading screenshot fastlane/metadata/android/xxx/en-US/images/phoneScreenshots/1_en-US.png...
+---------------+---------------------------+
|               Lane Context                |
+---------------+---------------------------+
| ENVIRONMENT   | xxx                    |
| PLATFORM_NAME | android                   |
| LANE_NAME     | android release_playstore |
+---------------+---------------------------+
[09:29:12]: Google Api Error: Unauthorized - Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

+------+---------------+-------------+
|          fastlane summary          |
+------+---------------+-------------+
| Step | Action        | Time (in s) |
+------+---------------+-------------+
| 1    | opt_out_usage | 0           |
| 💥   | supply        | 37          |
+------+---------------+-------------+
[09:29:12]: fastlane finished with errors

[!] Google Api Error: Unauthorized - Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
 [REPLACE THIS WITH YOUR INFORMATION] 

Environment

 [REPLACE THIS WITH YOUR INFORMATION] 

I am also experiencing this across several stores that have been publishing fine for years. Here is one of the failures.

🚫 fastlane environment 🚫

Stack

Key Value
OS debian_based buster/sid
Ruby 2.7.1
Bundler? false
Git git version 2.17.1
Installation Source ~/.rbenv/versions/2.7.1/bin/fastlane
Host Ubuntu 18.04.4 LTS debian_based buster/sid (4.14.291-218.527.amzn2.x86_64)
Ruby Lib Dir ~/.rbenv/versions/2.7.1/lib
OpenSSL Version OpenSSL 1.1.1 11 Sep 2018
Is contained false
Is homebrew false
Is installed via Fabric.app false

System Locale

Variable Value
LANG en_US.UTF-8 ✅
LC_ALL en_US.UTF-8 ✅
LANGUAGE en_US:en 🚫

fastlane files:

No Fastfile found

No Appfile found

fastlane gems

Gem Version Update-Status
fastlane 2.214.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.4.0
atomos 0.1.3
CFPropertyList 3.0.6
claide 1.1.0
colored2 3.1.2
nanaimo 0.3.0
rexml 3.2.6
xcodeproj 1.22.0
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
unicode-display_width 1.8.0
terminal-table 1.8.0
plist 3.7.0
public_suffix 5.0.3
addressable 2.8.5
multipart-post 2.3.0
word_wrap 1.0.0
optparse 0.1.1
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
artifactory 3.0.15
babosa 1.0.4
colored 1.2
highline 2.0.3
commander 4.6.0
excon 0.100.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
faraday-multipart 1.0.4
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
faraday-retry 1.0.3
ruby2_keywords 0.0.5
faraday 1.10.3
unf_ext 0.0.8.2
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.5
faraday-cookie_jar 0.0.7
faraday_middleware 1.2.0
fastimage 2.2.7
gh_inspector 1.1.3
json 2.3.0
mini_magick 4.12.0
naturally 2.2.1
rubyzip 2.3.2
security 0.1.3
xcpretty-travis-formatter 1.0.1
dotenv 2.8.1
bundler 2.1.4
simctl 1.6.10
jwt 2.7.1
uber 0.1.0
declarative 0.0.20
trailblazer-option 0.1.2
representable 3.2.0
retriable 3.1.2
mini_mime 1.1.5
memoist 0.16.2
multi_json 1.15.0
os 1.1.4
signet 0.17.0
googleauth 1.7.0
httpclient 2.8.3
webrick 1.6.0
google-apis-core 0.11.1
google-apis-playcustomapp_v1 0.13.0
google-apis-androidpublisher_v3 0.48.0
google-cloud-env 1.6.0
google-cloud-errors 1.3.1
google-cloud-core 1.6.0
google-apis-iamcredentials_v1 0.17.0
google-apis-storage_v1 0.19.0
rake 13.0.1
digest-crc 0.6.5
google-cloud-storage 1.44.0
emoji_regex 3.2.3
jmespath 1.6.2
aws-partitions 1.805.0
aws-eventstream 1.2.0
aws-sigv4 1.6.0
aws-sdk-core 3.180.3
aws-sdk-kms 1.71.0
aws-sdk-s3 1.132.1
uri 0.10.0
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
date 3.0.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
zlib 1.1.0
mutex_m 0.1.0
ostruct 0.2.0
strscan 1.0.3
io-console 0.5.6
delegate 0.1.0
fileutils 1.4.1
etc 1.1.0
singleton 0.1.0
open3 0.1.0
yaml 0.1.0
psych 3.1.0

generated on: 2023-09-12

 +------------------------------------+--------------------------------------+
|                        �[32mSummary for supply 2.214.0�[0m                         |
+------------------------------------+--------------------------------------+
| package_name                       | org.scriptureearth.qxl.salasaca.qui  |
|                                    | chua                                 |
| version_code                       | 20                                   |
| release_status                     | completed                            |
| track                              | production                           |
| metadata_path                      | play-listing                         |
| json_key                           | /secrets/playstore_api.json          |
| apk                                | /artifacts/qxl_Salasaca_Quichua_Bib  |
|                                    | lia-11.0.2.apk                       |
| skip_upload_apk                    | false                                |
| skip_upload_aab                    | false                                |
| skip_upload_metadata               | false                                |
| skip_upload_changelogs             | false                                |
| skip_upload_images                 | false                                |
| skip_upload_screenshots            | false                                |
| track_promote_release_status       | completed                            |
| validate_only                      | false                                |
| check_superseded_tracks            | false                                |
| timeout                            | 300                                  |
| deactivate_on_promote              | true                                 |
| changes_not_sent_for_review        | false                                |
| rescue_changes_not_sent_for_review | true                                 |
| ack_bundle_installation_warning    | false                                |
+------------------------------------+--------------------------------------+

DEBUG [2023-09-12 20:52:40.79]: Fetching a new access token from Google...
INFO [2023-09-12 20:52:41.49]: Preparing apk at path '/artifacts/qxl_Salasaca_Quichua_Biblia-11.0.2.apk' for upload...
INFO [2023-09-12 20:52:45.14]: 	Version Code: 20
INFO [2023-09-12 20:52:45.14]: Updating track 'production'...
INFO [2023-09-12 20:52:46.09]: Preparing to upload for language 'en-US'...
INFO [2023-09-12 20:52:46.72]: Uploading image file play-listing/en-US/images/featureGraphic.png...
INFO [2023-09-12 20:52:48.80]: Uploading image file play-listing/en-US/images/icon.png...
INFO [2023-09-12 20:52:50.74]: Uploading screenshot play-listing/en-US/images/phoneScreenshots/qxl1.png...
INFO [2023-09-12 20:52:52.44]: Uploading screenshot play-listing/en-US/images/phoneScreenshots/qxl2.png...
INFO [2023-09-12 20:52:54.29]: Uploading screenshot play-listing/en-US/images/phoneScreenshots/qxl3.png...
/root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane_core/lib/fastlane_core/ui/interface.rb:141:in `user_error!': \e[31m[!] Google Api Error: Unauthorized - Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.\e[0m (FastlaneCore::Interface::FastlaneError)
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:95:in `rescue in call_google_api'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:80:in `call_google_api'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:573:in `upload_image'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:290:in `block (2 levels) in upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:288:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:288:in `block in upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:281:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:281:in `upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:100:in `block (2 levels) in perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:92:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:92:in `block in perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:84:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:84:in `perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:35:in `perform_upload'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:40:in `block (2 levels) in run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:61:in `run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:13:in `start'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane/lib/fastlane/cli_tools_distributor.rb:115:in `take_off'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/bin/fastlane:23:in `<top (required)>'
	from /root/.rbenv/versions/2.7.1/bin/fastlane:23:in `load'
	from /root/.rbenv/versions/2.7.1/bin/fastlane:23:in `<main>'
/root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:230:in `check_status': Unauthorized (Google::Apis::AuthorizationError)
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/api_command.rb:137:in `check_status'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:202:in `process_response'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/upload.rb:174:in `process_response'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/upload.rb:259:in `execute_once'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:126:in `block (2 levels) in do_retry'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:123:in `block in do_retry'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:113:in `do_retry'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:104:in `execute'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-core-0.11.1/lib/google/apis/core/base_service.rb:418:in `execute_or_queue_command'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/google-apis-androidpublisher_v3-0.48.0/lib/google/apis/androidpublisher_v3/service.rb:1078:in `upload_edit_image'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:574:in `block in upload_image'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:81:in `call_google_api'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb:573:in `upload_image'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:290:in `block (2 levels) in upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:288:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:288:in `block in upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:281:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:281:in `upload_screenshots'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:100:in `block (2 levels) in perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:92:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:92:in `block in perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:84:in `each'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:84:in `perform_upload_meta'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/uploader.rb:35:in `perform_upload'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:40:in `block (2 levels) in run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:61:in `run'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/commands_generator.rb:13:in `start'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/fastlane/lib/fastlane/cli_tools_distributor.rb:115:in `take_off'
	from /root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/fastlane-2.214.0/bin/fastlane:23:in `<top (required)>'
	from /root/.rbenv/versions/2.7.1/bin/fastlane:23:in `load'
	from /root/.rbenv/versions/2.7.1/bin/fastlane:23:in `<main>'

+1
Same since this morning, with jobs who were running just fine moments before.

+------+------------------------+-------------+
|              fastlane summary               |
+------+------------------------+-------------+
| Step | Action                 | Time (in s) |
+------+------------------------+-------------+
| 1    | default_platform       | 0           |
| 2    | load_json              | 0           |
| 3    | increment_version_name | 0           |
| 4    | bundleRelease          | 664         |
| 💥   | upload_to_play_store   | 34          |
+------+------------------------+-------------+
[12:05:50]: fastlane finished with errors
[!] Google Api Error: Unauthorized - Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

the same :(

Our nightly build hit this same error about 9 hours ago. I re-ran the process 15 minutes ago and again received the error. Then I ran it again with the --verbose flag and this time the upload was successful! Maybe it was an issue on Google's end that they have resolved? My gut doubts that the --verbose flag had an effect.

@markpar I report above was executed with the --verbose flag and it was an error.

I think that this has been an issue with Google service accounts. My upload did not work and my RevenueCat service account also broke down.

Lots of folks are (were?) having the same issue here: #21091

hey i have same problem

+1
works after retry

Same problem here!

Same problem here

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

This worked for me.

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

That worked, thanks

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Worked for me as well. Thanks!

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Didn't help for screenshots uploading

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Didn't help for screenshots uploading

same here sadly

+1
I'm using MS Appcenter to build and publish the app, how can I set the root_url: "https://androidpublisher.googleapis.com/"?

I'm pretty sure the issue is on Google's end, because the request failure is completely random, sometimes it passes sometimes it doesn't.

When you're doing only one apk upload request to the Google API it can be enough to retry a couple of times until it passes, but if you need to upload new screenshots for example, that requires many Google API calls (one per image upload), so there is a way higher chance that one of them will fail along the many ones that are sent.


In the meantime—i.e. until Google fixes it on their end—I was able to apply a quick-and-dirty patch to my local copy of the fastlane gem:

  1. Open vendor/bundle/ruby/2.7.0/gems/fastlane-2.214.0/supply/lib/supply/client.rb in your favorite code editor
    • Adjust the path to wherever your local fastlane gem is located (e.g. if you don't use bundler or don't use vendor/bundle as your BUNDLE_PATH for your bundler config like we do)
    • Adjust the -2.214.0 in that path according to which fastlane version your project is using
      Apply the following changes to the call_google_api method
  2. Apply the following changes to the def call_google_api method:
     def call_google_api
+      tries_left ||= 5
       yield if block_given?
     rescue Google::Apis::Error => e
       error = begin
@@ -92,7 +93,13 @@ module Supply
         message = e.body
       end
 
-      UI.user_error!("Google Api Error: #{e.message} - #{message}")
+      if tries_left.positive?
+        UI.error("Google Api Error: #{e.message} - #{message} - Retrying...")
+        tries_left -= 1
+        retry
+      else
+        UI.user_error!("Google Api Error: #{e.message} - #{message}")
+      end
     end

Obviously this is a temporary workaround and dirty patch, that is only aimed to get you out of a bind if you need to call upload_to_play_store today and can't wait for Google to fix the issue on their end hopefully soon. Once you're done with it, you should ideally revert that patch (e.g. remove vendor/bundle then re-install the original fastlane gem code from scratch using bundle install again).


Note about why not making a PR to fastlane with that patch

I thought about submitting a PR to fastlane but I think this would need a nicer implementation than my dirty patch above — especially adding a max_retries option to Supply::Options that you could then pass as a parameter to upload_to_play_store, etc.

Also I'm pretty sure this is a very exceptional case that we should probably not officially cover for in fastlane's end but in GoogleApis' end, as the Google::Apis gem that supply uses internally already implements a retry mechanism.

Indeed, the reason why this mechanism from the Google:Apis gem doesn't retry in the case we're seeing here is because Google::Apis::AuthorizationError is not one of the codes for which they retry; which makes sense because if the error was really about the request not including an OAuth token in the headers or had incorrect credentials, there would be no point in retrying the exact same request (still without valid authentication) over and over anyway. Which kinda confirms that this being a random issue is really on Google servers' side.

Unfortunately, setting the root_url does not solve the issue...
This seems to be a timing issue like the lease on the authorization token is not long enough. The deployment does not always fail in the same spot and network speed seems to play apart as well.

The only way I have been able to get an app uploaded with upload_to_play_store is by disabling the image and screenshots.
I've even tried uploading them separately but it always seems to fail at some point uploading screenshots.

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
     skip_upload_images: true,
     skip_upload_screenshots: true,
    ...
)

Like @AliSoftware, I just wrote a script to repeatedly keep trying the deployment and it eventually goes through. It's a problem on Google's end.

When deploying manually I found a new paid applications agreement, I think it could be correlated, although accepting the agreement doesn't immediately fix this problem.

We just released fastlane 2.215.0 which contain some (opt-in) changes which optimize Google API calls during screenshots upload (sync_image_upload: true). That should help significantly reduce the number of requests done during skip_upload_screenshots: false and thus make it less likely to hit this random API error.

That sync_image_upload: option was not initially developed in the context of this issue — but rather in an unrelated goal of making supply not uploading screenshots that are already present in Google Play — and that won't fully solve the problem (which is on Google's side)… but reducing the likeliness of hitting the random issues with Google API like the one we see in this issue will still be a nice side-effect of that new opt-in option 🙂

We shipped fastlane 2.215.1 this weekend, which includes my patch to workaround this Google API issue.

Once you update to fastlane 2.215.1, set the SUPPLY_UPLOAD_MAX_RETRIES env var to an integer to auto-retry each randomly failed Google API error.

You can do this either in your fastalane/.env file (if you use one), or inside your Fastfile using ENV['SUPPLY_UPLOAD_MAX_RETRIES']='5' for example.

Alternatively, you can also pass that value on each call to fastlane (especially since this Google API random error is an issue on Google's side that will hopefully get resolved by Google soon-ish) via SUPPLY_UPLOAD_MAX_RETRIES=5 fastlane your_lane_that_calls_upload_to_play_store

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

This worked for me

2.215.1 + SUPPLY_UPLOAD_MAX_RETRIES did the trick for us!
Thank you !

2.216.0 + SUPPLY_UPLOAD_MAX_RETRIES did the trick for me.
Thanks @AliSoftware

2.215.1 + SUPPLY_UPLOAD_MAX_RETRIES did the trick for us! Thank you !

How can I add this to my Fastfile.. Kindly, drop screenshot of how you did it.

2.215.1 + SUPPLY_UPLOAD_MAX_RETRIES did the trick for us! Thank you !

Can you share a code snippet of how you set SUPPLY_UPLOAD_MAX_RETRIES?

2.215.1 + SUPPLY_UPLOAD_MAX_RETRIES did the trick for us! Thank you !

Can you share a code snippet of how you set SUPPLY_UPLOAD_MAX_RETRIES?

See #21507 (comment)
Description already given there!

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Worked as a charm! Thank you

As @anh1979 mentioned, after updating Fastlane version, we added the SUPPLY_UPLOAD_MAX_RETRIES to our Jenkins pipeline and it just worked...
Even saw the Retring... message in the logs

fl-21507

Someone on the Android DevRel team at Google contacted me 5h ago saying they were made aware of this and were monitoring this GitHub issue, and that the Play team had identified an issue which may have contributed to this issue and believe they have now fixed this. 🤞

They added:

It isn't confirmed that the issue that they identified and fixed was indeed the cause of the issue Fastlane has been experiencing, but we'd be interested to know whether users of Fastlane are now seeing an improvement, with no more failures, and no more need for retries?

So feel free to comment here to indicate if from now on your upload_to_play_store calls don't even need retrying anymore and the issue is fixed, or if you're still experiencing issues even after their patch.

@AliSoftware I'm not seeing our builds have to retry anymore. Just as a note like you mention.

Try setting the root_url:

upload_to_play_store(
    root_url: "https://androidpublisher.googleapis.com/",
    ...
)

Worked as a charm! Thank you

As an additional note, we started doing this before google fixed their systems and is seems like our build is getting lost in the aether as it says upload successful but the build never shows up in the google console.

I'm still getting this error and not able to resolve with the above, here is my lane:

lane :update_images do
ENV['SUPPLY_UPLOAD_MAX_RETRIES']='5'
supply(
root_url: "https://androidpublisher.googleapis.com/",
json_key: ENV["PLAY_STORE_KEY_FILEPATH"],
skip_upload_apk: true,
skip_upload_aab: true,
skip_upload_metadata: true,
skip_upload_changelogs: true,
skip_upload_images: false,
)
end