fixes the Json upload test
This commit is contained in:
parent
9e09e8ad17
commit
032e537ac3
1 changed files with 30 additions and 2 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
|
||||||
namespace testOauthClient.Controllers
|
namespace testOauthClient.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +21,7 @@ namespace testOauthClient.Controllers
|
||||||
using (var client = new HttpClient()) {
|
using (var client = new HttpClient()) {
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://dev.pschneider.fr/api/me");
|
var request = new HttpRequestMessage(HttpMethod.Get, "http://dev.pschneider.fr/api/me");
|
||||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
|
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
|
||||||
|
|
||||||
|
|
||||||
var response = await client.SendAsync(request, cancellationToken);
|
var response = await client.SendAsync(request, cancellationToken);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
@ -30,6 +30,34 @@ namespace testOauthClient.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> 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 {
|
protected string AccessToken {
|
||||||
get {
|
get {
|
||||||
var claim = HttpContext.User?.FindFirst("access_token");
|
var claim = HttpContext.User?.FindFirst("access_token");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue