node.jsoidc-providernode-oidc-provider

How to get access token and refresh token in the /token endpoint using OIDC provider


I tried to get the access token and refresh token in the /token endpoint. I got authorization code and I will pass the token endpoint but it's throwing grant request is invalid error. How to fix this issue

Configuration

const oidc = new Provider('http://localhost:3000', {
  clients: [
    {
      // client_id: 'foo',
      // redirect_uris: ['https://jwt.io'], // using jwt.io as redirect_uri to show the ID Token contents
      // response_types: ['id_token'],
      // grant_types: ['implicit'],
      // token_endpoint_auth_method: 'none',
      client_id: 'secret',
      redirect_uris: ['http://localhost:3000/api/v1'], // using jwt.io as redirect_uri to show the ID Token contents
      response_types: ['code'],
      grant_types: ['authorization_code', 'refresh_token'],
      token_endpoint_auth_method: 'none',
    },
    
  ],
  cookies: {
    keys: 'secret key',
  },

  features: {
    clientCredentials: {enable:true},
    introspection: {enable:true}
    
},
pkce: {
  required: true
},
token_endpoint_auth_method: "none",
});

Token API

enter image description here

How to fix this Issue. I tried many ways and referred many documentation but I could not get the solution


Solution

  • Your access token request is missing the PKCE code_verifier parameter.

    you can start your provider process with DEBUG=oidc-provider:* to get more details for these errors.