Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

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. This will take approximately 10 minutes and Google likes to change these screens often. Sorry.

  1. Visit https://console.developers.google.com/apis/credentials

  2. Create a project:

    Google APIs: Create project
  3. Enter chrome-webstore-upload and Create

  4. Click on Configure consent screen

  5. Select on External and Create

  6. Only enter the Application name (e.g. chrome-webstore-upload) and required email fields, and click Save

    Consent screen configuration
  7. On the 3rd screen, add your own email address:

    Test users selection
  8. Visit https://console.developers.google.com/apis/library/chromewebstore.googleapis.com

  9. Click Enable

  10. Visit https://console.developers.google.com/apis/credentials

  11. Click Create credentials > OAuth client ID:

    Create credentials
  12. Select Desktop app (or Other), enter chrome-webstore-upload and click Create

    Configure client type
  13. Save your clientId and clientSecret, these are 2 of the required 3 keys

  14. Visit https://console.cloud.google.com/apis/credentials/consent

  15. Click PUBLISH APP and confirm

    Publish app
  16. 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

  17. Follow its steps and warnings (this is your own personal app)

  18. Wait on this page:

    Last page of OAuth
  19. Run this in your browser console on that last page. It's a wizard to create your refresh_token:

(async () => {
  const response = await fetch('https://accounts.google.com/o/oauth2/token', {
    method: "POST",
    body: new URLSearchParams([
      ['client_id', prompt('Enter your clientId')],
      ['client_secret', prompt('Enter your clientSecret')],
      ['code', new URLSearchParams(location.search).get('approvalCode')],
      ['grant_type', 'authorization_code'],
      ['redirect_uri', 'urn:ietf:wg:oauth:2.0:oob']
    ]),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
  const json = await response.json();
  console.log(json);
  if (!json.error) {
    if (typeof copy === 'function') {
      copy(json.refresh_token);
      alert('The refresh_token has been copied into your clipboard. You’re done!');
    } else {
      console.log('Copy your token:', json.refresh_token);
      alert('Copy your refresh_token from the console output. You’re done!');
    }
  }
})();
  1. Done. Now you should have clientId, clientSecret and refreshToken. You can use these for all your extensions, but don't share them!