This repository was archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathusing_webstore_api.html
More file actions
267 lines (218 loc) · 8.03 KB
/
using_webstore_api.html
File metadata and controls
267 lines (218 loc) · 8.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
{{+bindTo:partials.standard_store_article}}
<p class="caution">
<b>Important:</b>
Chrome will be removing support for Chrome Apps on Windows, Mac, and
Linux. Chrome OS will continue to support Chrome Apps. Additionally,
Chrome and the Web Store will continue to support extensions on all
platforms.
<a href="http://blog.chromium.org/2016/08/from-chrome-apps-to-web.html">
Read the announcement</a> and learn more about
<a href="https://developers.chrome.com/apps/migration">
migrating your app</a>.
</p>
<h1>Using the Chrome Web Store Publish API</h1>
<h2 id="overview">Overview</h2>
<p>
The Chrome Web Store Publish API provides a set of REST endpoints for
programmatically creating, updating, and publishing items in the Chrome Web
Store. Using this API, you can automate the process of uploading and
publishing items into the store.
</p>
<h2 id="beforeyoubegin">Before you begin</h2>
<p>
To use the Chrome Web Store Publish API, you need to enable the API for your
project in the <a href="https://console.developers.google.com">Google
Developers Console</a>.
</p>
<ol>
<li>Visit the
<a href="https://console.developers.google.com">Google Developers
Console</a>.
</li>
<li>Create a new project or select an existing one.</li>
<li>In the sidebar on the left, select <b>APIs & auth</b>.</li>
<li>In the displayed list of available APIs,
set the status of the Chrome Web Store API to <b>ON</b>.
</li>
<li>Accept the Terms of Service.</li>
<li>In the sidebar on the left, select <b>Credentials</b>.</li>
<li>Find the lines labeled <b>Client ID</b> and <b>Client secret</b>.
Note that there may be a client ID without a client secret
for use with Compute Engine and App Engine.
In that case,
create a new client ID and client secret.
</li>
<li>To create the client ID and client secret,
click on <b>Create New Client ID</b>,
select <b>Installed Application</b>,
and <b>Other</b> under <b>Installed application type</b>.
</li>
<li>Get an access token:</li>
<p>
Once you have the client ID and client secret, you can retrieve an
access token to work with the API. For example, enter this URL in your
browser, replacing the $CLIENT_ID with the one for your app:
</p>
<pre>
https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&client_id=$CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob
</pre>
<p>
You will see a page asking you to accept permission for the requested
scope.
</p>
<p class="note"><b>Note</b>:
Make sure you are requesting the token using the Google Account
which owns the Chrome Web Store apps you want to manage. This account
can be different from the account you create the Google Developers
Console
project with. For example, you can create an application for other
developers to manage their apps, in which case you only need to register
a Google Developers Console project.
</p>
<img src="images/default_service_account.png"/>
<p>Click the Accept button and you will see a code that looks something like
this:</p>
<img src="images/copy_code.png"/>
<p>Use this value to request an access token.
For example, using <code>curl</code>,
you can get an access token by executing the following command
(replacing
the values of $CLIENT_ID, $CLIENT_SECRET, and $CODE with the values from
above):</p>
<pre>
> curl "https://accounts.google.com/o/oauth2/token" -d \
"client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$CODE&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob"
</pre>
<p>
This will return a result such as:
</p>
<pre>
{
"access_token" : "ya29...",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/rwn..."
}
</pre>
<p>
You can now use the access_token to call the API. You can also
use the refresh token to get future access tokens. Note that tokens
expire after 40 minutes.
</p>
<p class="note"><b>Note</b>:
For more information about getting OAuth 2.0 access tokens,
see <a href="https://developers.google.com/accounts/docs/OAuth2">Using
OAuth
2.0 to Access Google APIs</a>.
</p>
</ol>
<h2 id="usingtheapi">Using the API</h2>
<p>
Once you have an access token, your app can then use the Chrome Web Store
Publish API. There are endpoints for creating items, updating items, and
publishing items.
</p>
<p class="note"><b>Note</b>:
Currently, there is no API for setting an item’s metadata, such as
description. This has to be done manually in the <a
href="https://chrome.google.com/webstore/developer/dashboard">Chrome
Web Store Developer Dashboard.</a> More detail about the Web Store API
can be found <a
href="/webstore/api_index">here</a>.
</p>
<h3 id="uploadnew">Uploading a package to create a new store item</h3>
<pre>
Endpoint: https://www.googleapis.com/upload/chromewebstore/v1.1/items
Type: POST
Header Parameters: $TOKEN: the access token
Body content: the package file to upload
</pre>
Type the following example on the command line:
<pre>
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-X POST \
-T $FILE_NAME \
-v \
https://www.googleapis.com/upload/chromewebstore/v1.1/items
</pre>
<p class="note"><b>Note</b>: For a full description of the insert method, see
<a href="/webstore/webstore_api/items/insert">Items:Insert</a>.</p>
<h3 id="uploadexisitng">Uploading a package to update an existing store
item</h3>
<pre>
Endpoint: https://www.googleapis.com/upload/chromewebstore/v1.1/items/$APP_ID
Type: PUT
Header Parameters: $TOKEN: the access token
Body content: the package file to upload
</pre>
<p>
$APP_ID is the ID of the existing Web Store item.
</p>
<pre>
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-X PUT \
-T $FILE_NAME \
-v \
https://www.googleapis.com/upload/chromewebstore/v1.1/items/$APP_ID
</pre>
<p class="note">
<b>Note</b>: For a full description of the update method, see
<a href="/webstore/webstore_api/items/update">Items:Update</a>.</p>
<h3 id="publishpublic">Publishing an item to the public</h3>
<pre>
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID/publish
Type: POST
Header Parameters: $TOKEN: the access token
</pre>
<pre>
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-X POST \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID/publish
</pre>
<p class="note"><b>Note</b>: For a full description of publish method, see
<a href="/webstore/webstore_api/items/publish">Items:Publish</a>.</p>
<h3 id="trustedtesters">Publishing an item to trusted testers</h3>
<pre>
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID/publish
Type: POST
Header Parameters: $TOKEN: the access token, publishTarget: trustedTesters
</pre>
<pre>
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "publishTarget: trustedTesters" \
-X POST \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID/publish
</pre>
<p class="note"><b>Note</b>: For a full description of the publish method, see
<a href="/webstore/webstore_api/items/publish">Items:Publish</a>.</p>
<h3 id="checkstatus">Checking the upload status of an item</h3>
<pre>
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID?projection=draft
Type: GET
Header Parameters: $TOKEN: the access token
</pre>
<pre>
curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "Expect:" \
-X GET \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID?projection=draft
</pre>
<p class="note"><b>Note</b>: For a full description of the get method, see
<a href="/webstore/webstore_api/items/get">Items:Get</a>.</p>
{{/partials.standard_store_article}}