Fetching Profile Attributes using HTTP Header

This topic has 1 reply, 2 voices, and was last updated 5 years, 4 months ago by Peter Major.

  • Author
  • #16176

    Can anyone help me figure out how to retrieve user profile attributes such as uid/mail or givenName from the HTTP header. I have mapped [uid]=MYuid, [mail]=MYmail and [givenName]=MYgivenName in profile attribute map and i am using profile attribute fetch mode as HTTP HEADER.

    When i try to fetch the header in the protected URL using following script :
    var req = new XMLHttpRequest();
    req.open(‘GET’, document.location, false);
    var headers = req.getAllResponseHeaders().toLowerCase();

    i get following in header :
    accept-ranges: bytes content-type: text/html etag: “25a-54a33bb6af576” last-modified: wed, 08 mar 2017 08:15:31 gmt content-length: 602 date: wed, 08 mar 2017 08:15:34 gmt server: apache/2.4.25 (win64) openam web agent/4.0.0

    Can anyone guide me how to fetch the desired attributes(mail/uid/name) from the header to be displayed on the protected Webpage???

    Thanks in Advance

     Peter Major

    The headers are only injected on the server side and even then they are injected into the request headers. If you want to access user information using Javascript, you will either need to use HTTP_COOKIE mapping, or implement a REST endpoint (or something to that end) that returns the user details as part of the response body – the endpoint could simply just grab the data from request headers and then put them on the response body.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?