Cannot destructure property 'adapter' Custom auth

I am using custom authentication.
I am using ‘parse-server-firebase-auth’ module.
My config:

{

auth: {
firebase: new FirebaseAuthAdapter()
}

}

Full error:

error: Uncaught internal server error. Cannot destructure property ‘adapter’ of ‘loadAuthAdapter(…)’ as it is undefined. {“stack”:“TypeError: Cannot destructure property ‘adapter’ of ‘loadAuthAdapter(…)’ as it is undefined.\n at Object.getValidatorForProvider (/usr/src/app/node_modules/parse-server/lib/Adapters/Auth/index.js:159:7)\n at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:357:58\n at Array.map ()\n at RestWrite.handleAuthDataValidation (/usr/src/app/node_modules/parse-server/lib/RestWrite.js:352:45)\n at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:498:17\n at processTicksAndRejections (internal/process/task_queues.js:93:5)”}

Not sure what exactly the error is.

Update: I tried with dummy auth adapter, I still get the same error.
{

auth: {
firebase: {
validateAuthData: function(){return Promise.resolve();},
validateAppId: function(){return Promise.resolve();}
}
}
}

If you read their documentation, they provide examples of how to set up Parse Sever to use this adapter. Without more info it’s difficult to tell what the issue is. If you follow their instructions and still cannot get it to work, maybe you want to open an issue on their GitHub page? Because without looking into the adapter itself, it’s difficult to say.

Thanks for the reply, non of the custom authetication is working. I tried dummy auth adapter too.
The following config slso givingin me the same error exactly.
{

auth: {
firebase: {
validateAuthData: function(){return Promise.resolve();},
validateAppId: function(){return Promise.resolve();}
}
}
}

@Manuel any update. Thanks

I suggest you follow the instructions provided:

Thanks @Manuel, I did follow these as well. I am gettting the same error.

Not sure why?

I do not think it is anything to do with the firebase auth adapter. The problem is it’s not able to load the adapter.

Can you post your full Parse Server config and the relevant server logs? The setup in your first comment is not according to the docs.

Thanks @Manuel for looking into it. Here is the configurations and error

Server.js:

> const express = require('express');
> const ParseServer = require('parse-server').ParseServer;
> const http = require('http');
> const cors = require('cors');
> const firebaseAuthAdapter = require('parse-server-firebase-auth-adapter');
> 
> class Server {
>     constructor(config) {
>         this.databaseUri = config.databaseUri;
>         this.cloudCodeMain = config.cloudCodeMain;
>         this.appId = config.appId;
>         this.clientKey = config.clientKey;
>         this.masterKey = config.masterKey;
>         this.serverURL = config.serverURL;
>         this.mountPath = config.mountPath;
>         this.cacheRedisURL = config.cacheRedisURL;
>         this.liveQueryRedisURL = config.liveQueryRedisURL;
>         this.liveQueryClassNames = config.liveQueryClassNames;
>         this.liveQueryMountPath = config.liveQueryMountPath;
>         this.gcsProjectId = config.gcsProjectId;
>         this.gcsBucket = config.gcsBucket;
>     }
> 
>     run(port, mountPath, enableLiveQuery) {
>         const app = express();
> 	    app.use(cors());
>         const api = new ParseServer({
>             databaseURI: this.databaseUri,
>             cloud: this.cloudCodeMain,
>             appId: this.appId,
>             clientKey: this.clientKey,
>             masterKey: this.masterKey,
>             serverURL: this.serverURL,
>             liveQuery: {
>                 classNames: this.liveQueryClassNames,
>                 redisURL: this.liveQueryRedisURL
>             },
>             filesAdapter : {
>                 module: "@parse/gcs-files-adapter",
>                 options: {
>                     projectId: this.gcsProjectId,
>                     bucket: this.gcsBucket
>                 }
>             },
>             auth: {
>                 firebase: firebaseAuthAdapter
>             }
>         });
> 
>         app.use(mountPath, api);
> 
>         const httpServer = http.createServer(app);
>         httpServer.listen(port,()=>{
>             console.log('server running on port ' + port);
>         });
>         if (enableLiveQuery) {
>         
>             ParseServer.createLiveQueryServer(httpServer, {
>                 appId: this.appId,
>                 masterKey: this.masterKey,
>                 serverURL: this.serverURL,
>                 redisURL: this.liveQueryRedisURL,
>             });
>         }
>     }
> }

Error log:
2021-04-07 14:02:03.029 PDT error: Uncaught internal server error. Cannot destructure property ‘adapter’ of ‘loadAuthAdapter(…)’ as it is undefined. {“stack”:“TypeError: Cannot destructure property ‘adapter’ of ‘loadAuthAdapter(…)’ as it is undefined.\n at Object.getValidatorForProvider (/usr/src/app/node_modules/parse-server/lib/Adapters/Auth/index.js:159:7)\n at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:357:58\n at Array.map ()\n at RestWrite.handleAuthDataValidation (/usr/src/app/node_modules/parse-server/lib/RestWrite.js:352:45)\n at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:498:17\n at processTicksAndRejections (internal/process/task_queues.js:93:5)”}
2021-04-07 14:02:03.035 PDT TypeError: Cannot destructure property ‘adapter’ of ‘loadAuthAdapter(…)’ as it is undefined. at Object.getValidatorForProvider (/usr/src/app/node_modules/parse-server/lib/Adapters/Auth/index.js:159:7)
2021-04-07 14:02:03.035 PDT at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:357:58
2021-04-07 14:02:03.035 PDT at Array.map ()
2021-04-07 14:02:03.035 PDT at RestWrite.handleAuthDataValidation (/usr/src/app/node_modules/parse-server/lib/RestWrite.js:352:45)
2021-04-07 14:02:03.035 PDT at /usr/src/app/node_modules/parse-server/lib/RestWrite.js:498:17
2021-04-07 14:02:03.035 PDT at processTicksAndRejections (internal/process/task_queues.js:93:5)

I haven’t looked into the adapter but the release is from 3 years ago. If you have installed the adapter using npm, it is possible that the adapter interface has changed since then.

What you could do is debug Parse Server and set a exception breakpoint. That should tell you what the issue is.

To mitigate the possibility of issues custom to your setup, I suggest you use the Parse Server Example repo, make Parse Server work without the auth adapter and then add the adapter.

The Parse Server is working with or without the firebase adapter. but the adapter not loading by Parse Server.

@Manuel I do see the adapters interface is same.

I found the problem. It is nothing to do with the Parse-Server or Adapter. I was using node:-slim base image to build the container.

Some how it was causing the issue (not exactly sure why). But when I changed the base image to a non-slim version, it was working fine.

@Manuel Is there any know reason?

Not known to me at least :slight_smile: Glad you solved it.