OAuth correct place to put the public key? #505
-
Following the google steps on enabling OAuth in extensions there is a step where you have to provide the public key in the manifest.json. This works if I place it in the manifest on import { defineConfig } from "wxt";
// https://wxt.dev/guide/configuration.html
export default defineConfig({
srcDir: "src",
publicDir: "public",
manifest: {
permissions: ["storage", "identity"],
//@ts-expect-error - Key isn't a valid property of the UserManifest type
key: "PUBLIC_EXTENSION_KEY",
oauth2: {
client_id: "yourExtensionOAuthClientIDWillGoHere.apps.googleusercontent.com",
//If you're following along with the google tutorial they say you don't need to include any scopes and suggest using an array with an
//empty string. This is outdated and you need to include the following scopes at a minimum.
scopes: ["openid", "email", "profile"],
},
},
}); This is obviously not the correct place to put it as the public key would be the same when deploying to other web stores. My question is where should I put the public key or browser specific manifest settings so they'll show up when I run in dev? What else I've triedThere doesn't seem to be a way to do browser specific settings from the manifest documentation and anything browser specific seems to be on the entrypoints. Seems the best option I have now is to set the key when |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The manifest field can be a function, and the browser being targeted is available in the first argument. import { defineConfig } from "wxt";
const clientIds = {
chrome: "...",
edge: "...",
firefox: "...",
// ...
};
// https://wxt.dev/guide/configuration.html
export default defineConfig({
srcDir: "src",
publicDir: "public",
manifest: ({ browser }) => ({
permissions: ["storage", "identity"],
//@ts-expect-error - Key isn't a valid property of the UserManifest type
key: "PUBLIC_EXTENSION_KEY",
oauth2: {
client_id: clientIds[browser],
//If you're following along with the google tutorial they say you don't need to include any scopes and suggest using an array with an
//empty string. This is outdated and you need to include the following scopes at a minimum.
scopes: ["openid", "email", "profile"],
},
}),
}); This is mentioned in the API reference, but that is super hard to read, so I'll add info to the manifest page you linked. |
Beta Was this translation helpful? Give feedback.
I've updated the docs: https://wxt.dev/guide/manifest.html#per-browser-configuration