500 error after getting the token in oauth2-basic plugin

I am facing a weird error that others seem to have solved. Basically, I am getting the token from the API but no user details API calls are being made. Instead, the callback URL fails with 500 without any error message.

From the logs,

OAuth2 Debugging: response status 200

From POST https://developer-dev.api.autodesk.com/authentication/v2/token

Headers:
--- !ruby/hash-with-ivars:Faraday::Utils::Headers
ivars:
  :@names:
    user-agent: User-Agent
    content-type: Content-Type
    authorization: Authorization
elements:
  User-Agent: Faraday v2.14.0
  Content-Type: application/x-www-form-urlencoded
  Authorization: Basic xxx


Body:
--- '{"access_token":"xxxx","token_type":"Bearer","expires_in":3599,"refresh_token":"xxxx"}

  '

Processing by Users::OmniauthCallbacksController#complete as HTML
  Parameters: {"code"=>"xxx", "state"=>"d77d766602c9302ad6967569883d4c41ef0ac9847d0b85f8", "provider"=>"oauth2_basic"}
OAuth2 Debugging:       after_authenticate response:

      creds:
      ---
token: xxx
refresh_token: xxx
expires_at: 1767886006
expires: true


      uid:

      info:
      ---
name:


      extra:
      --- {}


Completed 500 Internal Server Error in 81ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)

I do not get any error. So I am not sure what is causing the issue. I ensured to set the OAuth2 fetch user details, OAuth2 user JSON URL and OAuth2 JSON user ID path etc but I do not see any API call being made to user details API at all.

Any info would be much appreciated

I have both the server as well as docker access by the way. Any debugging to try out, I can give it a try