Google Chrome¶
Commands¶
Operations for Chrome are invoked as $ webstoremgr chrome <command>. Parameters used in this section are:
client_id,client_secret
- Your client API id obtained in the Google Developers Console. Refer to using webstore.
code
- One-time code used to generate a refresh token. Obtained through the
initcommand.
refresh_token
- Reusable token which is used for generating access tokens. It is obtained through the
authcommand.
app_id
- ID of an extension as listed in the Dashboard. Click on More Info next to the extension to find out. Its format is e.g.
abcdefghijklmnopqrstuvwxyzabcdef.
filename
- Name of an extension file (.zip, .crx) on your filesystem.
target
- Audience for publishing. Two accepted values:
publicandtrusted.
Supported Chrome Webstore commands are:
initInvocation:
webstoremgr chrome init <client_id>Prints information for the user on how to begin authentication. Chrome webstore requires an OAuth authentication which requires opening of the provided link in a web browser whilst signed in to Google.
Opening the provided link will prompt the user with a request for access to their webstore. Upon approving the request, a code is provided. This code may be used to generate a refresh token using the
authcommand.Having access to the webstore is necessary for the function of this tool. It does not send any personal information anywhere.
authInvocation:
webstoremgr chrome auth <client_id> <client_secret> <code>Exchanges your one-time code for a reusable
refresh tokenwhich can be later used for authentication.These three parameters should be stored securely, as they grant automated access to your webstore identity.
gen-tokenInvocation:
webstoremgr chrome gen-token <client_id> <client_secret> <refresh_token>Use refresh token to generate an access token. The access token has a limited lifespan (1 hour).
createInvocation:
webstoremgr chrome create [-t,--filetype] <client_id> <client_secret> <refresh_token> <filename>Optional parameter
-tor--filetypespecifies what type of archive the given file is. Accepted values arecrx(default) orzip.Create (upload) a new extension to the webstore. It will not be published.
It will be assigned a new
app_id, this will be printed on the standard output.
uploadInvocation:
webstoremgr chrome upload [-t,--filetype] <client_id> <client_secret> <refresh_token> <app_id> <filename>Optional parameter
-tor--filetypespecifies what type of archive the given file is. Accepted values arecrx(default) orzip.Upload a new version of an existing extension to the webstore. It will not be published.
publishInvocation:
webstoremgr chrome publish --target <target> <client_id> <client_secret> <refresh_token> <app_id>Parameter target specifies the audience of users to publish to. Accepted values are
publicortrusted.Publish an extension to a given audience.
repackInvocation:
webstoremgr chrome repack <filename>Transform a crx archive into a zip.
crx archive is obtained through Chrome developer tools (pack an extension). When uploading to the Webstore, zip is needed.
This tool accepts both zip and crx for uploading tasks. This is a convenience method if used in combination with other tools.
Script mode¶
Script mode for Chrome offers all functions of the command line tool. Heading of each list item is an example of how to call the given function in a script. The given parameters correspond to command mode parameters, see section above for details.
chrome.init client_id client_secret refresh_tokenInitialize the Chrome store. Saves the given parameters as a global state which is used in subsequent steps.
You must call this function before any others that require authentication.
chrome.setapp app_idSet the app_id parameter for future method calls.
chrome.new filenameCreate a new extension from the archive pointed to by
filename. Calling this function will set the internalapp_idvariable.Only accepts ZIP archives. To upload a CRX, you need to run
chrome.unpackandzipfunctions. See generic functions.
chrome.update filenameUpdate an existing extension. Its ID must be set by calling
chrome.setappfirst. Details are identical tochrome.newfunction.
chrome.publish targetPublish an extension to the given target (
publicortrusted).Its ID must be set by calling
chrome.setappfirst.
chrome.check_version expected_version timeoutAssertion function to check if the published version is the same as expected.
The currently published app is compared to the
expected_versionparameter. If they are not equal, the comparison is repeated after several seconds until thetimeoutduration expires. If they are still not equal, script terminates with a nonzero exit code.
chrome.unpack archive target_dirUnpack a CRX file to the given target directory.