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",
}
}
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;
}
.......
}
In this example, the custom data is stored in the
cookieValue property.
Additional References
- To know more about JavaScriptEmbedding
- JavaScript API reference
- Help documentation on authorizeAPI.header