I need to store a JWT token to use it through several instances of the same orchestration in BizTalk Server 2013 R2.
How can I store it and call it in each instances? Local storage? Registry key? anywhere else?
I need to store a JWT token to use it through several instances of the same orchestration in BizTalk Server 2013 R2.
How can I store it and call it in each instances? Local storage? Registry key? anywhere else?
What you need to do is have a token manager class that is a Static class. Once that is instantiated it will can retain your JWT token in it's private variable and persist as long as you don't restart the host instance. You will also want to hold the time the token was last fetched and fetch a new one if it has expired.
Below is a mock example of what it would look like.
public static class TokenManager
{
private static DateTime _sessionLastRefreshDate = DateTime.Now;
private static string _JWTToken = string.Empty;
public static string GetSession(...)
{
//get current date time
DateTime now = DateTime.Now;
//get the difference from the last time the token was fetched
TimeSpan diff = now.Subtract(_sessionLastAccessDate);
if (_sessionId == string.Empty || (diff.TotalMinutes >= *TokenTimeOut*)
{
// Fetch JWT Token here
_sessionId = *NewJWTToken*;
_sessionLastRefreshDate = DateTime.Now;
}
//give the session ID to the caller
return _sessionId;
}
}