<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007dD7X4CAKOkta Classic EngineSingle Sign-OnAnswered2025-03-17T09:01:54.000Z2022-05-06T12:49:27.000Z2022-05-13T20:04:53.000Z

f4las (f4las) asked a question.

How to tell which IDP was used for login?

We have several identity providers (IdPs) set up and we need to know which a user used after they log in. Ideally we could add the IdP ID as a claim to the access token, but I'm open to any method. Thanks!


  • Hello @f4las (f4las)​  Thank you for reaching out to our Community!

     

    This can be reviewed within the System Log, you should have a log that mentions "Authenticate user via IDP" which will tell you if the user has authenticated through an IDP.

    Using this query "displayMessage eq "Authenticate user via IDP" and target.id eq "0oaekmxsezXIH5Cko2p7" and target.alternateId eq "Azure"" you can find authentication through a specific IDP.

    Note that target.id eq "0oaekmxsezXIH5Cko2p7" is the ID for the IDP and target.alternateId eq "Azure" is the name of that specific IDP

    If you do not know the ID for the IDP you can use the simple part of the query:

    displayMessage eq "Authenticate user via IDP" and target.alternateId eq "Azure"

    Expand Post
  • f4las (f4las)

    Hi @paul.stiniguta1.508386743840768E12 (Okta, Inc.)​, thanks for the quick response! Should this method work for all identity providers? I am seeings logs for an Org2Org IDP, but not for a google IDP.

     

    I have been looking into the session api, and it appears to have the IDP in the session information, but I am struggling to get the session id. It looks like I should be able to call {oktaBaseurl}/api/v1/sessions/me but am currently fighting CORS - do you know if this strategy is possible?

    Expand Post
  • f4las (f4las)

    I found the CORS configuration that solves my problem (at {oktaBaseAdminUrl}/admin/access/api/trusted_origins).

     

    The SDK has the endpoint built in, though the typescript models don't seem to match as expected:

    import { SessionObject } from "@okta/okta-auth-js";

    // ...

    const { oktaAuth } = useOktaAuth();

      interface AugmentedSession extends SessionObject {

       id: string; // todo I'm not sure why SessionObject doesn't have this

      }

      const sessionId = await oktaAuth.session.get().then(s => (s as AugmentedSession).id)

    I'm sure this code needs to be more robust, but it's working for now

    Expand Post
This question is closed.
Loading
How to tell which IDP was used for login?