Articles in this section
Category / Section

How to pass custom data to authorization server?

Published:

In some scenarios, you may need to send custom data, such as cookies, to the authorization server to confirm if the requestor is logged-in or to process the data. This can be achieved using the authorizationServer header property.

Sending Custom Data in JavaScript

To send custom data to the authorization server, you can use the following code snippet:

authorizationServer: {
    url: authorizationServerUrl,
    headers: {
        "Cookie": "Set-Cookie: sessionId=38afes7a8",
    }
}

image.png

In this example, we pass a cookie value in the authorization server header property.

Retrieving Custom Data in Backend

To retrieve the custom data in your backend authorization server endpoint, you can use the following code snippet in C#:

[HttpPost]
        [Route("GetDetails")]
        public string GetDetails([FromBody] object embedQuerString)
        {
            bool isHeaderPresent = Request.Headers.ContainsKey("Cookie");
            if(isHeaderPresent){
                Request.Headers.TryGetValue("Cookie", out var headerValue);
                var cookieValue = headerValue;            
            }
            
          .......
        }
 

image.png

In this example, the custom data is stored in the cookieValue property.

Additional References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Soundarya Mani Meharan
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied