GetSecurityToken
The GetSecurityToken API returns a Mongoose security token for a specific user, which can be used to authenticate requests when calling the API directly.
Note: This topic is for REST version 1. See GetSecurityToken for the REST version 2.
| GET | /{responsetype}/token/{config} |
|---|---|
| http://localhost/IDORequestService/MGRESTService.svc/js/token/CSI_DALS | |
Parameters
| Name | In | Required? | Description |
|---|---|---|---|
| responsetype | Path | Yes | Response request data format
Specify any of these values:
|
| config | Path | Yes | The name of a configuration available on the application server |
Headers
| Name | Description |
|---|---|
| userid | Mongoose username |
| password | Mongoose user password |
Request data
None
Response data in XML format
If successful, the call returns a neatly packaged security token.
<MGRestTokenResponse xmlns="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Message>Success</Message> <Token>b/XdI6IQzCviZOGJ0E+002DoKUFOPmVDkwpQDb...YOdU2ThSw==</Token> </MGRestTokenResponse>
Response data in JSON format
If successful, the call returns a neatly packaged security token.
{
"Message": "Success",
"Token": "b/XdI6IQzCviZOGJ0E+002DoKUFOPmVDkwpQDb...YOdU2ThSw=="
}
Response data in JS format
If successful, the call returns the security token itself (no envelope).
b/XdI6IQzCviZOGJ0E+002DoKUFOPmVDkwpQDb...YOdU2ThSw==
Example
This example code retrieves a Mongoose security token for the given user ID, password, and configuration name.
string token = string.Empty;
using ( HttpClient client = new HttpClient() )
{
// provide your Mongoose credentails in the request url
string config = "CSI_DALS";
string requestUrl = $"http://server/IDORequestService/MGRESTService.svc/js/token/{config}";
// provide your Mongoose credentials as headers
client.DefaultRequestHeaders.Add( "userid", "sa" );
client.DefaultRequestHeaders.Add( "password", "" );
// send the get request
HttpResponseMessage response = client.GetAsync( requestUrl ).Result;
using ( HttpContent content = response.Content )
{
Task<string> result = content.ReadAsStringAsync();
// this contains your token
token = result.Result;
}
}