How to get refresh token using an automated way?

To get refresh token, we need to hit okta authorize endpoint which redirects us to login page. Once you login, you will get the code on your redirect uri which will be used to get refresh token.

Mine is not a browser based application but rest api architecture so I generate the token manually by following the above process every time we need a new token. But now I want to automate this process and decided to write an api to do this process. Everything seems fine to me except the login page coming in between which is a blocker to me. Is there another way to get the code or refresh token via api? or is there a way to by-pass the login page?

Any help is appreciated.

@ssaini1 Hi, if you are using okta-auth-js then you may try . Please make sure that your token expiration time is less that Okta session lifetime

@Lijia This does not match my requirement. I am looking for an API where i can pass the okta creds and get the PKCE code. Later, i can take the code to get new refresh token.

I cant use getWithoutPrompt method because it requires session token.