通过chrome web store api中的api-key进行身份验证

我想自动化chrome扩展部署,并且大部分都遵循本指南:https://developer.chrome.com/webstore/using_webstore_api . 我在开发人员控制台中创建了一个项目,激活了Chrome Web Store API . 下一步是创建正确的凭据 . 有三个不同的,当我让谷歌帮助我选择它时告诉我API密钥可以很好地用于这个API,所以我做了 .

我的问题:我如何使用此API密钥进行API调用?我尝试将密钥包含在文档中指出的参数中,但这不起作用 . 如果这是我真正不理解的错误方法,那么开发人员控制台会建议这些身份验证 .

当我尝试在不使用chrome或其他浏览器的构建服务器上自动化时,我无法真正使用OAuth凭据 .

curl \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "Expect:" \
-X GET \
-v \
"https://www.googleapis.com/chromewebstore/v1.1/items/ITEM_ID?projection=draft&key=API_KEY"

结果是

https://www.googleapis.com/chromewebstore/v1.1/items/ITEM_ID\?projection\=draft\&key\=API_KEY
*   Trying 172.217.17.234...
* Connected to www.googleapis.com (172.217.17.234) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /chromewebstore/v1.1/items/ITEM_ID?projection=draft&key=API_KEY HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.43.0
> Accept: */*
> x-goog-api-version: 2
> Content-Length: 0
>
< HTTP/1.1 401 Unauthorized
< Vary: X-Origin
< WWW-Authenticate: Bearer realm="https://accounts.google.com/"
< Content-Type: application/json; charset=UTF-8
< Date: Thu, 15 Sep 2016 14:14:18 GMT
< Expires: Thu, 15 Sep 2016 14:14:18 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
* Connection #0 to host www.googleapis.com left intact
{"error":{"errors":[{"domain":"global","reason":"required","message":"Login Required","locationType":"header","location":"Authorization"}],"code":401,"message":"Login Required"}}

我也尝试将其设置为 Headers ,但这些都不起作用 .

回答(0)