google-api-ruby-client icon indicating copy to clipboard operation
google-api-ruby-client copied to clipboard

`forbidden` exception when calling `commit_edit`

Open talothman opened this issue 3 years ago • 1 comments

Publishing to the store worked consistently for the past year until mid-last week. See below description of issue.

Environment details

  • OS: Ubuntu 16.04.7
  • Ruby version: 3.2.2
  • Gem name and version: 'google-api-client', '~> 0.53.0'

Steps to reproduce

  1. Ensure GOOGLE_APPLICATION_CREDENTIALS is setup correctly.
  2. Run code below.
  3. See resultant failure message.

Code example


auth = Google::Auth.get_application_default(['https://www.googleapis.com/auth/androidpublisher'])
publisher = Google::Apis::AndroidpublisherV3::AndroidPublisherService.new
publisher.authorization = auth

# increase timeouts
publisher.client_options.open_timeout_sec = 180
publisher.client_options.read_timeout_sec = 180
publisher.client_options.send_timeout_sec = 180

# start a new edit
edit = publisher.insert_edit(PACKAGE_NAME)

# upload the app bundle
bundle = publisher.upload_edit_bundle(PACKAGE_NAME, edit.id, upload_source: BUNDLE_NAME.to_s,
                                                             content_type: 'application/octet-stream')

# update the alpha track to point to this APK
release = Google::Apis::AndroidpublisherV3::TrackRelease.new(version_codes: [bundle.version_code], status: "completed")
track = Google::Apis::AndroidpublisherV3::Track.new(track: "alpha", releases: [release])
publisher.update_edit_track(PACKAGE_NAME, edit.id, "alpha", track) # save the modified track object

# commit the edit
publisher.commit_edit(PACKAGE_NAME, edit.id)

Resulting exception:

/usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:239:in `check_status': forbidden: The caller does not have permission (Google::Apis::ClientError)
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/api_command.rb:135:in `check_status'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:202:in `process_response'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:321:in `execute_once'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:126:in `block (2 levels) in do_retry'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:123:in `block in do_retry'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
	from /usr/local/bundle/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:113:in `do_retry'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:104:in `execute'
	from /usr/local/bundle/gems/google-apis-core-0.11.1/lib/google/apis/core/base_service.rb:418:in `execute_or_queue_command'
	from /usr/local/bundle/gems/google-api-client-0.53.0/generated/google/apis/androidpublisher_v3/service.rb:80:in `commit_edit'
	from /builds/dt-wind/frontline-android/devops/googleplay.rb:59:in `<main>'

talothman avatar Oct 04 '23 21:10 talothman

Found issue was incorrect permission changes for the service account on playstore side. This is not an issue on the client side.

Having said that, it would seem that the exception type is a little mislead. This should have ideally returned a AuthenticationError over a ClientError.

talothman avatar Oct 06 '23 14:10 talothman