diff --git a/testOauthClient/Controllers/HomeController.cs b/testOauthClient/Controllers/HomeController.cs index db43ac18..09471c4d 100755 --- a/testOauthClient/Controllers/HomeController.cs +++ b/testOauthClient/Controllers/HomeController.cs @@ -1,11 +1,10 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Mvc; +using Yavsc.Helpers; namespace testOauthClient.Controllers { @@ -22,6 +21,7 @@ namespace testOauthClient.Controllers using (var client = new HttpClient()) { var request = new HttpRequestMessage(HttpMethod.Get, "http://dev.pschneider.fr/api/me"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken); + var response = await client.SendAsync(request, cancellationToken); response.EnsureSuccessStatusCode(); @@ -30,6 +30,34 @@ namespace testOauthClient.Controllers } } + + [HttpPost] + public async Task PostDeviceInfo(CancellationToken cancellationToken) + { + /* using (var client = new HttpClient()) { + var request = new HttpRequestMessage(HttpMethod.Post, "http://dev.pschneider.fr/api/gcm/register"); + + request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken); + var json = JsonConvert. + SerializeObject(new Yavsc.Models.Identity.GoogleCloudMobileDeclaration { DeviceId= "devid01", GCMRegistrationId = "1234" } ); + var content = new StringContent(json, Encoding.UTF8, "application/json"); + var response = await client.SendAsync(request, cancellationToken); + response.EnsureSuccessStatusCode(); + + return View("Index", model: await response.Content.ReadAsStringAsync()); + }*/ + var res = await new SimpleJsonPostMethod( + "http://dev.pschneider.fr/api/gcm/register", + "Authorization: Bearer "+AccessToken).InvokeJson( new { + GCMRegistrationId = "testGoogleRegistrationIdValue", + DeviceId = "TestDeviceId", + Model = "TestModel", + Platform = "External Web", + Version = "0.0.1-rc1" + } ); + return Json(res); + } + protected string AccessToken { get { var claim = HttpContext.User?.FindFirst("access_token");