Skip to content

Instantly share code, notes, and snippets.

@poychang
Created June 27, 2019 03:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poychang/283b83d985e03026aa9efc098f20b1d2 to your computer and use it in GitHub Desktop.
Save poychang/283b83d985e03026aa9efc098f20b1d2 to your computer and use it in GitHub Desktop.
[如何產生上傳 Chrome Web Store 的 API 金鑰等資訊] 可取得 Travis CI 處理自動化上架時,需要的 CLIENT_ID、CLIENT_SECRET 和 REFRESH_TOKEN 資訊

How to generate Google API keys

chrome-webstore-upload uses the Chrome Web Store API.

Here's how to get its 3 access keys: clientId, clientSecret, refreshToken

Note: the names you enter here don't really matter.

  1. Visit https://console.developers.google.com/apis/api/chromewebstore/overview

  2. Create a project:

    chrome-apis-create-project
  3. Enter a name (e.g. webstore-yourextensionname)

  4. Visit https://console.developers.google.com/apis/api/chromewebstore/overview again

  5. Enable the API:

    chrome-apis-enable-webstore
  6. Open Credentials > Create credentials > OAuth client ID:

    create-credentials
  7. Click on Configure consent screen:

    configure consent screen
  8. Enter a product name (e.g. yourextensionname) and save

  9. Select Other and click Create

    client type id
  10. Save your ✅ clientId and ✅ clientSecret, these are your keys.

  11. Place your clientId in this URL and open it:

     https://accounts.google.com/o/oauth2/auth?client_id=YOUR_CLIENT_ID&response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&redirect_uri=urn:ietf:wg:oauth:2.0:oob
    
  12. Follow its steps and copy the authcode it shows on the last page:

    auth code
  13. Run this in your browser console.
    It's a wizard to create and copy a curl into your clipboard:

     copy(`curl "https://accounts.google.com/o/oauth2/token" -d "client_id=${encodeURIComponent(prompt('Enter your clientId'))}&client_secret=${encodeURIComponent(prompt('Enter your clientSecret'))}&code=${encodeURIComponent(prompt('Enter your authcode'))}&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob"`);alert('The curl has been copied. Paste it into your terminal.')
    
  14. Paste the generated code in your terminal and run it.

  15. Save your ✅ refreshToken:

    access token
  16. Done. Now you should have ✅ clientId, ✅ clientSecret and ✅ refreshToken. You can use these for all your extensions, but don't share them!

REF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment