This commit is contained in:
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Http.Formatting;
|
||||||
|
|
||||||
namespace qbridge.Controllers
|
namespace qbridge.Controllers
|
||||||
{
|
{
|
||||||
@@ -60,13 +61,14 @@ namespace qbridge.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bugbug: It's not prompting for the company I want like the playground does...what's up with that? Is it because I need to follow the OpenID method rather than the "web app" method??
|
||||||
[HttpGet("Start/{qboid}")]
|
[HttpGet("Start/{qboid}")]
|
||||||
public async Task<IActionResult> GetAsync([FromQuery]string qboid)
|
public async Task<IActionResult> GetAsync([FromRoute]string qboid)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(qboid)){
|
if (string.IsNullOrWhiteSpace(qboid))
|
||||||
|
{
|
||||||
|
return BadRequest("QBOID value is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
//GET THE DISCOVERY DOCUMENT
|
//GET THE DISCOVERY DOCUMENT
|
||||||
@@ -94,7 +96,7 @@ namespace qbridge.Controllers
|
|||||||
{"scope", "openid" },
|
{"scope", "openid" },
|
||||||
{"redirect_uri",REDIRECT_URI },
|
{"redirect_uri",REDIRECT_URI },
|
||||||
{"response_type","code"},
|
{"response_type","code"},
|
||||||
{"state","MyUniqueStateID"}
|
{"state",qboid}
|
||||||
};
|
};
|
||||||
|
|
||||||
url = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(AuthorizationEndpoint, queryParams);
|
url = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(AuthorizationEndpoint, queryParams);
|
||||||
@@ -234,10 +236,24 @@ TOKEN: {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("Revoke/{id}")]
|
[HttpGet("Revoke/{tokenToRevoke}")]
|
||||||
public async Task<IActionResult> RevokeAsync()
|
public async Task<IActionResult> RevokeAsync([FromRoute]string tokenToRevoke)
|
||||||
{
|
{
|
||||||
//Revoke the access token for the app for the unique ID specified
|
//Revoke the access token for the app for the unique ID specified
|
||||||
|
/*
|
||||||
|
|
||||||
|
POST https://developer.api.intuit.com/v2/oauth2/tokens/revoke HTTP/1.1
|
||||||
|
Accept: application/json
|
||||||
|
Authorization: Basic UTM0dVBvRDIwanp2OUdxNXE1dmlMemppcTlwM1d2
|
||||||
|
NzRUdDNReGkwZVNTTDhFRWwxb0g6VEh0WEJlR3dheEtZSlVNaFhzeGxma1l
|
||||||
|
XaFg3ZlFlRzFtN2szTFRwbw==
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"token": "{bearerToken or refreshToken}"
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
//GET THE DISCOVERY DOCUMENT
|
//GET THE DISCOVERY DOCUMENT
|
||||||
//Discovery document contains the actual current endpoints to use for various ops
|
//Discovery document contains the actual current endpoints to use for various ops
|
||||||
@@ -255,35 +271,36 @@ TOKEN: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var request = new HttpRequestMessage(HttpMethod.Post, revocation_endpoint);
|
var request = new HttpRequestMessage(HttpMethod.Post, revocation_endpoint);
|
||||||
request.Headers.Add("Accept", "application/json");
|
request.Headers.Add("Accept", "application/json");
|
||||||
request.Headers.Add("User-Agent", "AyaNova-QBridge");
|
request.Headers.Add("User-Agent", "AyaNova-QBridge");
|
||||||
request.Headers.Add("Authorization", "Basic " + Base64Encode(CLIENT_ID + ":" + CLIENT_SECRET));
|
request.Headers.Add("Authorization", "Basic " + Base64Encode(CLIENT_ID + ":" + CLIENT_SECRET));
|
||||||
|
|
||||||
var bodyParams = new Dictionary<string, string>()
|
// var bodyParams = new Dictionary<string, string>()
|
||||||
{
|
// {
|
||||||
{"code", code },
|
// {"code", code },
|
||||||
{"redirect_uri", REDIRECT_URI },
|
// {"redirect_uri", REDIRECT_URI },
|
||||||
{"grant_type","authorization_code"}
|
// {"grant_type","authorization_code"}
|
||||||
};
|
// };
|
||||||
request.Content = new FormUrlEncodedContent(bodyParams);
|
|
||||||
|
|
||||||
|
string jfrag = $"{{\"token\":\"{tokenToRevoke}\"}}";
|
||||||
|
|
||||||
|
request.Content = new StringContent(jfrag, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
var client = _clientFactory.CreateClient();
|
var client = _clientFactory.CreateClient();
|
||||||
|
|
||||||
var response = await client.SendAsync(request);
|
var response = await client.SendAsync(request);
|
||||||
|
|
||||||
JObject AccessTokenObject = null;
|
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
string data = await response.Content.ReadAsStringAsync();
|
return Content("Token revoked");
|
||||||
AccessTokenObject = JObject.Parse(data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AccessTokenObject = null;
|
return Content("Token revocation FAILED!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user