jwt token always return a '401 Unathorized' response

I’m building a ASP.NET Core Web API that will consume some data entities on Dynamics 365 F&O.

I’ve registered an APP on Azure and generated the necessary credentials (client_id, client_secret, etc)

When i hit the endpoint directly from postman, this is what i get:

And when I used this access_token gotten from the image above to make calls on the oData endpoint, I get a ‘200 OK’ response:

Everything is fine up to this point…

But I’ve wrapped the whole access token retrieval http call into a .NET Web API controller and when it hit the endpoint for this controller, I get access token…Cool!

But when I use the jwt token marked in black to make requests, i get a ‘401 unauthorized’ response, but despite checking from jwt.io, the token looks OK.

Someway somehow my token gets invalidated.

I need help on this…

Eventually got the solution, had to shake things around in my token retrieval logic.