How to use adapter in oidc-provider

110 views Asked by At

I am trying to create an oidc-provider and new to this. I wanted to use adapter which will query db and get particular client who is trying to login. For this i have adapter as below:-

   export class MongoDbAdapter {

    async find(id) {
        const doc = await Clients.find({ client_id: id })
        console.log(doc)
        return doc
    }

}

my configuration flie looks like

import { MongoDbAdapter } from "./adapter/clientAdapter.js";
let client;
const configuration = {
  adapter: MongoDbAdapter,
  clientBasedCORS() {
    return true
  },
  claims: {
    address: ['address'],
    email: ['email', 'email_verified'],
    phone: ['phone_number', 'phone_number_verified']
  },
  // other configurations
}

in my index.js i have used it as

import oidc from 'oidc-provider'
import configuration from './configuration.js'
// other imports
        const provider = new oidc('http://localhost:3009', { ...configuration })

// express related code

 app.use((err, req, res, next) => {
            if (err instanceof SessionNotFound) {
                // handle interaction expired / session not found error
            }
            next(err);
        });
        app.use('', provider.callback())

when i am using adapter then i am getting error from /auth api of oidc error:-

error: server_error

error_description: oops! something went wrong

iss: http://localhost:3009

not able to find whatis the issue. If i remove adapter and add client by fetching it from db its working fine and i am able to get code. but issue with that is i can not implement dynamic registration. Can any one tell what i am doing wrong in usin adapter.

Thanks in advance

0

There are 0 answers