
mqme3 (mqme3) asked a question.
OKTA multi-factor Authentication + Java + RestAssured: /authorize API call directs me back to login page
I'm trying to perform OKTA authentication via API calls to access one of the apps our company is using. I am able to successfully authenticate through a web browser, so I am attempting to reproduce the same series of API calls executed in the web browser within the RestAssured API in Java.
To do this, we need to invoke a call to {oktaURL}/oauth/v1/token, which takes several form parameters: client_id, redirect_uri, grant_type, code and code_verifier. By generating this token, we can use it to authorize all calls made in the app by adding a header named "Authorization" whose value is "Bearer {token}".
I have almost all of the parameters but I am attempting to generate the "code" parameter using another API call to {oktaURL}/oauth2/v1/authorize, after having successfully generated an "okta_key" parameter for this service through successful authentication.
When the service call {oktaURL}/oauth2/v1/authorize runs in the browser, a response is returned whose "Location" header contains the "code" encoded within the URL:
"{oktaURL}*code=KPgE5DqCNbmqcg4pec_n&state=RKIjvKP9H0X0SZ0TtxBLsEUn647HiPXalMlR65n0f3tgdeURLGobMFZ5Jagdfjxb"
However, when I execute this same service call in RestAssured, I do NOT get this value and get this instead for the Location:
{oktaLoginURL}?fromURI=%2Foauth2%2Fv1%2Fauthorize%2Fredirect%3Fokta_key%3Ds8hTa0bGWkg0aJftmalC2QJ2_ydaJT2-pJKLWnpW5SI
It appears that the attempt to authorize is redirecting me to the login page. Is there any reason why this is happening?

Hi Richard,
Please open up a case with us so we can check the behavior that you experience when you access the application, from there we can make suggestions or escalate it to the proper team.
Thank You,
Valentin Branzoi
Technical Support Engineer
Okta Global Customer Care