Generates a KeyMaster token for the given IAuthenticationParameters.
![](../icons/collapse_all.gif)
C# | Visual Basic | Visual C++ |
string GenerateToken( IAuthenticationParameters authParameters, IKeyMasterFormatter formatter )
Function GenerateToken ( _ authParameters As IAuthenticationParameters, _ formatter As IKeyMasterFormatter _ ) As String
String^ GenerateToken( IAuthenticationParameters^ authParameters, IKeyMasterFormatter^ formatter )
![](../icons/collapse_all.gif)
- authParameters (IAuthenticationParameters)
- The authentication parameters.
- formatter (IKeyMasterFormatter)
- The formatter to apply to the token.
![](../icons/collapse_all.gif)
The token as formatted by the given IKeyMasterFormatter
![](../icons/collapse_all.gif)
KeyMaster offers no guarantees regarding thread safety, if there is a possibility that multiple calls to this method could be made at the same time, then the calling code should take steps to ensure that only once call can be in progress at a given point in time.
![](../icons/collapse_all.gif)
This example generates a token and formats it using the StandardKeyMasterFormatter which is suitable for use by StreamLink.NET, StreamLink for Silverlight and StreamLink for Java.
![](../icons/CopyCode.gif)
using System; using System.Collections.Generic; using System.Text; using Caplin.KeyMaster; using Caplin.KeyMaster.Configuration; namespace KeyMasterSnippets { class CreatingKeyMasterInstance { const string PEM_FILE_LOCATION = "c:\\myprivatekey.pem"; IKeyMaster CreateKeyMasterInstance() { // Create a KeyMaster configuration using a private key stored as a PEM format file. // This constructor may throw an exception; handling of it has been omitted for clarity. IKeyMasterConfiguration configuration = new PEMKeyMasterConfiguration(PEM_FILE_LOCATION); // Create a keymaster instance. IKeyMaster keymaster = new KeyMaster(configuration); return keymaster; } } }