Browser side code to get user details

Hi

I am using a third party tool call statuspage.io along with OKTA as the SSO I only have selected access to adjust the page in basic terms add a bit of html, css, javascript.

I dont have access to the server so cant write any PHP/CURL and seems OKTA blocks the use of CORS.

Now I can see https://okta.com/api/v1/sessions/me contains the email address, so what I would like to do is from my page that they land on after loggin in via OKTA is to access this β€˜me’ and capture the email address in order to customize the experience.

Any help much appreciated

You can use an ajax call like this to get the session, then in the success just do with it as you please:

$.ajax({
type: "GET",
url: https://okta.com/api/v1/sessions/me,
accept: "application/json",
contentType: "application/json",
crossDomain: true,
xhrFields: {
    withCredentials: true
},
success: function (response) {
    alert(response.login);
},
error: function (xhr, status, error) {
    window.location.replace(signInUrl);
}

});

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.