-
Notifications
You must be signed in to change notification settings - Fork 0
/
OAuthController.cs
55 lines (46 loc) · 1.36 KB
/
OAuthController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThermostatAutomation.Controllers
{
public class AccessTokenRequest
{
public string grant_type { get; set; }
public string refresh_token { get; set; }
public string code { get; set; }
public string redirect_uri { get; set; }
public string scope { get; set; }
}
public class OAuthController : Controller
{
[HttpPost]
public IActionResult AccessToken(AccessTokenRequest tokenRequest)
{
if (tokenRequest.refresh_token == "rtoken")
{
var response = new
{
access_token = "atoken",
token_type = "example",
expires_in = 3600,
refresh_token = "rtoken"
};
return Ok(response);
}
else if (tokenRequest.code == "1")
{
var response = new
{
access_token = "atoken",
token_type = "example",
expires_in = 3600,
refresh_token = "rtoken"
};
return Ok(response);
}
return BadRequest();
}
}
}