I am trying to make JSON output returned from a single controller action (don't want to set it global) as like this (PascalCase) :
{
"AuthenticationResult": {
"AccessToken": "",
"ExpiresIn": 0,
"TokenType": "",
"RefreshToken": "",
"IdToken": ""
}
}
DTO Class:
public class AuthResponse
{
public AuthenticationResult authenticationResult { get; set; }
}
public class AuthenticationResult
{
[JsonProperty("AccessToken")]
public string AccessToken { get; set; }
public int ExpiresIn { get; set; }
public string TokenType { get; set; }
public string RefreshToken { get; set; }
public string IdToken { get; set; }
}
Controller Method:
public async Task<IHttpActionResult> GetAuthenticationToken(string Guid = null)
{
try
{
var AuthResponse = await _Business.GetAuthenticationTokenAsync(Guid, null);
return Ok(AuthResponse, this);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
The DTOs AuthResponse
and AuthenticationResult
are not used elsewhere.