Custom Provider // KeyCloak (Migration v3 to v4)

System Information
  • Strapi Version: V4.1.7
  • Operating System: Node 16 Alpine Docker
  • Database: Postgres
  • NPM Version: 8.5.5

Dear community,

I’m get frustrated getting a custom provider to work. My custom provider (KeyCloak) works perfectly on v3. Now when I setup a clean installation of strapi v4 and try to implement a new custom provider I get ERR_INVALID_REDIRECT of my Chrome Browser.


This is my folder tree:


    case 'keycloak': {
      const keycloak = purest({
        provider: 'keycloak',
        config: {
          keycloak: {
            '': {
              __domain: {
                auth: {
                  auth: { bearer: '[0]' },
              '{endpoint}': {
                __path: {
                  alias: '__default',
        .request((err, res, body) => {
          if (err) {
          } else {
            callback(null, {
              username: body.username,


  keycloak: {
    enabled: false,
    icon: 'key',
    key: '',
    secret: '',
    callback: `${baseURL}/keycloak/callback`,
    scope: ['email'],

If I could see which redirect Strapi tries to implement that would help me a lot. Does any of you see any issue with my configuration?

I was following this tutorial for doing the migration:

Already found the issue. The issue wasn’t in my code. Unfortunately the database don’t get updated if you change the server url or the grant-config. I had to manually change the grant settings in the strapi core settings table. Hope that help some people who also face the same issue.

1 Like

Hello, can you please tell me which tables do you updated? Thanks

Hi Larse, I’m pretty new to Stepi v4 and I’m trying to implement from scratch Keycloak as another provider, I couldn’t understand much of the Tutorial you linked in your question, so I’m asking, as you made a working one, if you could share to me what’s the content on all the files I can see in the screenshot you sent.
Thank you in advance.