How can I perform an OAuth 2.0 request to the JIRA Tempo API?

I need assistance with transitioning to the OAuth 2.0 flow for my console application, which extracts data from the JIRA Tempo API due to their removal of access token support. I’ve successfully obtained the Client ID and Client Secret for the OAuth 2.0 access. I’m attempting to connect to their API using this code structure:

HttpClient tempoHttpClient = new HttpClient();
tempoHttpClient.DefaultRequestHeaders.Authorization = 
    new AuthenticationHeaderValue("Bearer", _tempoAccessToken);

var url = $"https://api.tempo.io/core/3/worklogs/user/{userId}?from={from:yyyy-MM-dd}&to={to:yyyy-MM-dd}";
var response = await tempoHttpClient.GetAsync(url);

However, I’m receiving an “Unauthorized” status. I used “localhost” as my redirect URI when generating the Client ID/Secret because it’s for a console application. What could be the issue?

One potential issue you might be facing is with the redirect URI and the authorization flow. Even though you’re using a console application, when you initially get the authorization code, it should be redirected to a valid URI. Try using a tool like ngrok to expose your local server to the internet and use that as the redirect URI. Also, ensure you have exchanged the authorization code for the access token successfully and that the access token being used is not expired or invalidated. Double-check all tokens and API permissions to ensure they are correctly set up.

If you you aren’t seeing the consent screen, it might be the temproary state paramater issues. Make sure it is consistent. Cookies might also cause URL params from getting passed correctly. Take a look if yur session settings need adjusting or try in diff browser.