Hello Strapists, I just started playing with strapi and I want to:
- Define env vars for login providers I need
- Let the application create or update the configuration on startup
I’m looking at the default users-permissions
plugin and I see the configuration object I probably need in server/bootstrap/grant-config.js
but I can’t find a way to use this in the way I want.
This topic has been created from a Discord post (1268888710443962398) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord
Config Sync plugin is probably your best bet.
Hey there,
How do I sync the providers with Config Sync? From what I understood, their config name is plugin_users-permissions_grant
and it’s excluded from CS by default, and I couldn’t figure out how to export this config.
Ah you are correct.
Then you can not use Config Sync but you’ll have to manually insert in to the core_store table.
From the bootstrap function
And then you can you env vars like you suggested
Alright I understand thank you so much!!
Solution:
Exporting the provider config is impossible via Config-Sync as this config requires env variables.
Instead I configured them in Strapi Bootstrap at ./src/index.ts
.
I used the Strapi core store to set the config via strapi.store({ key: 'grant', ...other stuff }).set(new data here)
method. I don’t remember off the top of my head the other two properties to be passed to the store but I can post the rest tomorrow 
Complete code example:
// ./src/index.ts
export default {
register(strapi){/*...*/}
bootstrap({strapi}) {
const pluginStore = strapi.store({ type: 'plugin', name: 'users-permissions', key: 'grant' })
const oldData = pluginStore.get()
pluginStore.set({ value: {
...oldData,
// New stuff here
})
}
}