Dotnet console app needs bearer token for external api access

From my console app, I need to call an API which is expects okta bearer token as an input.

How can I check if logged in user is authenticated against Okta hosted login and access his access token for API call?

Note: If user is not authenticated or token is expired, I would like to ask user to open browser independently to authenticate against okta via message on console window (similar to az login).

the following blog post might apply to your use-case