Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.