Skip to content

Instantly share code, notes, and snippets.

@jmarkoff
Created November 15, 2018 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarkoff/fc19ec171da009c8e0ccb31dc87daf06 to your computer and use it in GitHub Desktop.
Save jmarkoff/fc19ec171da009c8e0ccb31dc87daf06 to your computer and use it in GitHub Desktop.
require "google/apis/playcustomapp_v1"
# Auth Info
KEYFILE = "KEYFILE.json" # PATH TO JSON KEYFILE
DEVELOPER_ACCOUNT = "DEVELOPER_ACCOUNT_ID" # DEVELOPER ACCOUNT ID
# App Info
APK_PATH = "FILE_NAME.apk" # PATH TO SIGNED APK WITH V1+V2 SIGNATURES
APP_TITLE = "APP TITLE"
LANGUAGE_CODE = "EN_US"
scope = "https://www.googleapis.com/auth/androidpublisher"
credentials = JSON.parse(File.open(KEYFILE, "rb").read)
authorization = Signet::OAuth2::Client.new(
:token_credential_uri => "https://oauth2.googleapis.com/token",
:audience => "https://oauth2.googleapis.com/token",
:scope => scope,
:issuer => credentials["client_id"],
:signing_key => OpenSSL::PKey::RSA.new(credentials["private_key"], nil),
)
authorization.fetch_access_token!
custom_app = Google::Apis::PlaycustomappV1::CustomApp.new title: APP_TITLE, language_code: LANGUAGE_CODE
play_custom_apps = Google::Apis::PlaycustomappV1::PlaycustomappService.new
play_custom_apps.authorization = authorization
play_custom_apps.create_account_custom_app(
DEVELOPER_ACCOUNT,
custom_app,
upload_source: APK_PATH,
) do |created_app, error|
unless error.nil?
puts "Error: #{error}"
else
puts "Success: #{created_app}."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment