Hi
I am working on generating an OAuth token in business central through Codeunit OAuth2, For this, I am using AcquireTokenByAuthorizationCode function, which takes clientId, ClienSecret, etc as a parameter and generates an OAuth token, which expires after a certain time, if we use this function then user interaction is required, the user needs to give access to a specific resource(snippet attached).
in the same codeunit there is a function AcquireTokenWithClientCredentials which takes almost the same parameter and generates a token without user interaction. But when we used the token generate from this function the request response is 400,403, whereas if we use the token generate from AcquireTokenByAuthorizationCode then the response is 200. I want to schedule a job that automatically gets the access token after a certain time(without user interaction). Does anyone know why the token generated without user interaction is not valid? I have added the snippet of both implementations.
With user interaction
Without user interaction