Articles in this section

How to Pass Custom Data to an Authorization API

Published:

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

Sending Custom Data in JavaScript

To send custom data to the authorize API, you can use the following code snippet:

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

image.png

In this example, we pass a cookie value in the authorize API header property.

Retrieving Custom Data in Backend

To retrieve the custom data in your backend authorize API 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)
Access denied
Access denied