I need to send a token when I make this Api call to confirm i am logged in the game .
How can I do it?
public static async Task<HttpResponseMessage> SaveStats(int _monstersKilled, int _score, int _round, string _gameMode, int _userId)
{
HttpResponseMessage response = null;
try
{
Stats stats = new Stats
{
MonstersKilled = _monstersKilled,
BestScore = _score,
HighestRound = _round,
GameMode = _gameMode
};
string endpoint = "GameStats/Update/" + _userId;
response = await client.PutAsJsonAsync(endpoint, stats);
response.EnsureSuccessStatusCode();
Debug.WriteLine("STATS SAVED for "+_userId);
}
catch (Exception ex)
{
Debug.WriteLine("\tERROR {0}", ex.Message);
}
return response;
}
public static void Initialize()
{
client.BaseAddress = new Uri("http://localhost:5000/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
}