OAuth2.0 unable to get access_token

I am trying to integrate Company House into a Node.js application using the sandbox environment. Initially I registered a web application and attempted to authorize it using client_id and client_secret. I successfully received the code and state. However, when I try to exchange the code for an authorization token, I get the following error:

requestToken exception Cannot invoke "uk.gov.companieshouse.authentication.models.Oauth2AuthorisationsDao.getToken()" because "oad" is null

Appreciate your support with this.