private (bool condition, string message, string token) GetManagementApiToken() { var payload = new ManagmentApiTokenRequestModel { grant_type = "client_credentials", client_id = _applicationSetting.AuthorityManagementClientId, client_secret = _applicationSetting.AuthorityManagementClientSecret, audience = $"{_applicationSetting.Authority}api/v2/" }.ToJSON().StringContent(); var tokenRequestResult = _httpService.Post($"{_applicationSetting.Authority}oauth/token", payload); _logService.Log(LogLevel.Info, tokenRequestResult.result); if (!tokenRequestResult.condition) { return(tokenRequestResult.condition, "Issue getting token for management api", string.Empty); } var response = JsonConvert.DeserializeObject <UserResponseModel>(tokenRequestResult.result); return(tokenRequestResult.condition, "Success", response.access_token); }
public static string ToJSON(this ManagmentApiTokenRequestModel jsonObject) { return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonObject)); }