How to programmatically login to application? Skip to main content
https://support.okta.com/help/answers?id=9062a000000bmcjqai&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Michael GantzMichael Gantz 

How to programmatically login to application?


I have created an integration test framework to test an application we wrote.  Several instances of this application use Okta for login.  I'm trying to add support for logging in via Okta to our test framework.  

First, there is no actual browser involved.  We are using Apache Http Client to test our deployed client.

What I have been able to do so far is this:

1) Using the Java SDK I've called AuthApiClient.authenticate to get a valid session token.

2) I've done an http GET request to our Okta app EMBED LINK URL with "?onetimetoken={sessionToken}" appended to the Okta URL.

3) This responds with some HTML that has a form in it with an id of "appForm".

4) We are not executing JavaScript in HTML because we are just getting the content using http client.

5) I'm able to extract the data from the form, this includes the SAML Response.

6) I'm able to call an HTTP Post with the data from that form which logs me into the application.

This all seems rather dirty when we get to the HTML portion.  Is there a non JavaScript way of doing this? Or, conversly is there a way of getting the SAML Response in Json format so I don't have to parse apart HTML?

Or, faily all that, is there a completely different way of logging into an application without using a browser all together?

Thanks.

 

 

Costel CurcaCostel Curca (Okta, Inc.)
Hi Michael, if you cannot find the answer in our documentation please send an email to developers@okta.com since they are more qualified to assist you.