The client.callbackParams function accepts the input parameter types: string | http.IncomingMessage | http2.Http2ServerRequest.
When an argument of type http.IncomingMessage is passed to this function, it throws the following error:
'incoming message body missing, include a body parser prior to this method call'.
To Reproduce
fastify.post('/callback', async function (req: FastifyRequest, res) {
const params = googleClient.callbackParams(req.raw); // <- throws the error
const tokenSet = await googleClient.callback('https://client.example.com/callback', params, { nonce: nonces.val });
console.log('received and validated tokens %j', tokenSet);
console.log('validated ID Token claims %j', tokenSet.claims().email);
});
Expected behaviour
The http.IncomingMessage type does not include a body property by default.
Although the documentation mentions that the body must be parsed before calling this function, this seems to be a design flaw. If the function accepts a parameter of a specific type (http.IncomingMessage), it should be capable of handling that type without throwing an error. The possible solutions are either to removehttp.IncomingMessage from the accepted types or to extend the accepted type to include the body property.
Environment:
openid-client version: 5.7.0
node version: 20.11.1
Additional context
Add any other context about the problem here.
[x ] the bug is happening on latest openid-client too.
[x ] i have searched the issues tracker on github for similar issues and couldn't find anything related.
Describe the bug
The
client.callbackParams
function accepts the input parameter types:string | http.IncomingMessage | http2.Http2ServerRequest
.When an argument of type
http.IncomingMessage
is passed to this function, it throws the following error:'incoming message body missing, include a body parser prior to this method call'
.To Reproduce
Expected behaviour The
http.IncomingMessage
type does not include a body property by default.Although the documentation mentions that the body must be parsed before calling this function, this seems to be a design flaw. If the function accepts a parameter of a specific type (
http.IncomingMessage
), it should be capable of handling that type without throwing an error. The possible solutions are either to removehttp.IncomingMessage
from the accepted types or to extend the accepted type to include thebody
property.Environment:
Additional context Add any other context about the problem here.