# SSO 406 error C#

**URL:** <https://forums.eveonline.com/t/sso-406-error-c/224014>\
**Category:** Third Party Developers\
**Created:** [March 6, 2020, 8:18am UTC](https://forums.eveonline.com/t/sso-406-error-c/224014 "2020-03-06T08:18:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawn313](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/shawn313/32/413011_2.png) [@shawn313](https://forums.eveonline.com/u/shawn313)\
**Post date:** [March 6, 2020, 8:18am UTC](https://forums.eveonline.com/t/sso-406-error-c/224014/1 "2020-03-06T08:18:25Z")

</div>

Having a issues with getting the token with the code the response body is empty the status code i get is 406 any ideas? this is a blazer app in c#

@page “/CallBack”  
@using System.Linq;  
@using System.Net.Http;  
@using System.Net.Http.Headers;  
@using System.Text;  
@using System.Threading.Tasks;  
@using Microsoft.AspNetCore.Components;  
@using Microsoft.Extensions.Configuration;  
@using System.Text.Json;  
@using eveFastResponseFleet.Data;  
@inject IConfiguration Configuration  
@inject NavigationManager navManager

### CallBack
  
@_@foreach (var item in Token)  
{_  
   
 _@item.access\_token   
 @item.expires\_in   
 @item.token\_type   
 @item.refresh\_token_   
   
_}_@  
@code {  
private static readonly HttpClient \_httpClient = new HttpClient();  
private EveSSO Token;  
string code { get; set; }  
private static HttpClient \_client = new HttpClient()  
{  
};  
protected override async Task OnInitializedAsync()  
{  
var uri = navManager.ToAbsoluteUri(navManager.Uri);  
if (Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query).TryGetValue(“code”, out var param))  
{  
code = param.First();  
}  
byte toBytes = Encoding.ASCII.GetBytes(Configuration[“EsiConfig:ClientId”] + “:” + Configuration[“EsiConfig:SecretKey”]);  
string base64 = System.Convert.ToBase64String(toBytes);  
var dict = new Dictionary\<string, string\>();  
dict.Add(“grant\_type”, “authorization\_code”);  
dict.Add(“code”, code);  
\_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Basic”, base64);  
\_httpClient.DefaultRequestHeaders.Host = “[login.eveonline.com](http://login.eveonline.com)”;  
\_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(“eve-frf”);  
\_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/x-www-form-urlencoded”));  
string body = “grant\_type=authorization\_code&code=”+code;  
var requestMessage = new HttpRequestMessage()  
{  
Method = new HttpMethod(“POST”),  
RequestUri = new Uri(“[https://login.eveonline.com/v2/oauth/token](https://login.eveonline.com/v2/oauth/token)”),  
Content = new FormUrlEncodedContent(dict)  
};  
var response = await \_httpClient.SendAsync(requestMessage);  
var responseStatusCode = response.StatusCode;  
var responseBody = await response.Content.ReadAsStringAsync();  
Token = JsonSerializer.Deserialize\<EveSSO\>(responseBody);  
}  
}

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [March 6, 2020, 2:11pm UTC](https://forums.eveonline.com/t/sso-406-error-c/224014/2 "2020-03-06T14:11:53Z")

</div>

Seems you’re missing the `Content-Type: application/x-www-form-urlencoded` header. See [https://docs.esi.evetech.net/docs/sso/web\_based\_sso\_flow.html](https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html) for docs on the full flow.

---

<div class="post-metadata">

**Author:** ![shawn313](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/shawn313/32/413011_2.png) [@shawn313](https://forums.eveonline.com/u/shawn313)\
**Post date:** [March 6, 2020, 5:13pm UTC](https://forums.eveonline.com/t/sso-406-error-c/224014/3 "2020-03-06T17:13:48Z")

</div>

> [@shawn313](#):
>
> \_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/x-www-form-urlencoded”));

this line should fulfill the requirement but if i remove that line it works so thank you for putting my on the right path

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [June 4, 2020, 5:13pm UTC](https://forums.eveonline.com/t/sso-406-error-c/224014/4 "2020-06-04T17:13:54Z")

</div>

Closed on June 4, 2020, 5:13pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
