jwize
jwize

Reputation: 4165

Where can you find or how can you create a chrome extension key and place it in your manifest.json file?

Looking to implement Oauth2 in my Chrome extension

I have been researching how to implement oauth2 on a chrome extension. I have been stuck for quite some time. I eventually got information to use chrome.identity in my background.ts file.

Here is my manifest.json

...
"permissions": [
    "identity"
],
"oauth2": {
    "client_id": "855289137547-bd37ghe68neqevqs47esitvc99rb5f8d.apps.googleusercontent.com",
    "scopes":["https://www.googleapis.com/auth/userinfo.email"]
  },
  
"background": {
    "scripts": [
        "background.js",
        "runtime.js"
    ]
},
...

Call the chrome.identity API

There is a method on the API that is called getAuthToken which I am trying to call. When I try to call this method I get the following:

// background.ts
chrome.identity.getAuthToken({ interactive: true }, (token)  => {
  // store token here
});

Error

Unchecked runtime.lastError: OAuth2 request failed: Service responded with error: 'bad client id: 855289137522-bd37ggg68neqevqs47esitvc99rb5f8d.apps.googleusercontent.com'.

I checked multiple times and I can confirm that that the id is the same as I my console developer credentials.

Maybe it needs a key in the manifest

I was assuming that I have to have a key in my manifest.json. So, I followed the documentation at the following link where it says to follow the steps:

  1. At the Developer Dashboard, click Add new item.
  2. Click Choose file and select the .zip extension directory and upload it.
  3. Without filling in additional fields, select Save Draft and return to dashboard.

Find the extension under Your Listings and click on more info. From the popup, copy the public key and add it to the manifest inside the unzipped directory under the "key" field.

However, I looked everywhere but could not find the "more info" link or any other info leading me to a key.

Upvotes: 4

Views: 708

Answers (2)

hydroweaver
hydroweaver

Reputation: 149

Key is available in the new UI --> Package on left side menu --> Public Key

Upvotes: 3

bytrangle
bytrangle

Reputation: 1139

At of time of my post (August 2020), if you go to the Developer Dashboard, you will always be directed to the new UI, which doesn't contain the More Information section, which means you can't find the public key.

AFAIK there is no other way to get the public key. You can't substitute your application ID because it is a hashed version of the public key,

Look for the Welcome popup on the bottom left corner of the screen and click on opt out link in tiny font to revert to the legacy interface.

Upvotes: 1

Related Questions