SAML assertion via API Skip to main content
https://support.okta.com/help/answers?id=906f0000000xzh3iao&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:
Nick SteelNick Steel 

SAML assertion via API

Hi

Is it possible to get a SAML assertion for an application via the Okta API? We are building some automation around fetching the SAML assertion to authenticate against an application's API which requires that we pass it the SAML assertion to it.  

We currently have it working by screen scraping the response form Okta and parsing the SAML response blob out. Its not elegant and potentially a fragile solution. Ideally we'd like to do it via an API call instead, as far as I can tell from reading the docs, its not something that's supported. Has anyone figured out otherwise?


 

Madhu Mahadevan - SEMadhu Mahadevan - SE (Okta, Inc.)
Nick SteelNick Steel
Thanks Madhu - 

How woudl this work for applications that have MFA enabled?

 
api-workday api-workdayapi-workday api-workday
HI Nick,

with the authentication API you *should* be able to do this even with MFA

The sequence would be something like this
$step1 = oktaCheckCreds -oOrg prod -username username@domain.tld -password "d0nut Tella sole"
[ POST https://domain.okta.com/api/v1/authn ]
{
    "username":  "username@domain.tld",
    "context":  {
                    "userAgent":  "PowerShell API Wrapper"
                },
    "password":  "d0nut Tella sole",
    "relayState":  "/a/relayState/Value"
}

$step2 = oktaAuthnQuestionWithState -oOrg prod -stateToken $step1.stateToken -fid $step1._embedded.factors[0].id -answer 'the one that matched'
[ POST https://varian.okta.com/api/v1/authn/factors/ufs99vmy99akKn9901d9/verify ]
{
    "stateToken":  "00OMiEKt9varTzj-4twcWSYoqtOa9OB2yj9Z0oYkaz",
    "answer":  "the one that matched"
}

$step2.sessionToken
00P1Zgh0gRgb0FkwrJqSaCvF-OX68ZGIpu7KKJt-gu

Now with sessionToken in hand

http://developer.okta.com/docs/examples/session_cookie.html#retrieving-a-session-cookie-by-visiting-an-application-embed-link

Now what i've described is based on the user being required to perform MFA to authenticate to Okta. Not based on the application configuration.

I'd actually love to get some input on this one from Karl.

If the user isn't forced to perform MFA to authenticate can i perform or force a similar transaction that would produce a sessionToken that would satisfiy an application embed + sessionToken for an application that requied MFA?

Anyway, hopefully that helps.

-Matt