This commit is contained in:
@@ -10,14 +10,21 @@ using System.Net.Http.Formatting;
|
||||
|
||||
namespace qbridge.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
//[Route("[controller]")]
|
||||
[Route("")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
public class OAuthRedirectController : ControllerBase
|
||||
{
|
||||
public const string CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
|
||||
public const string CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
|
||||
public const string REDIRECT_URI = "https://localhost:5001/OAuthRedirect";
|
||||
|
||||
#if (DEBUG)
|
||||
public const string REDIRECT_URI = "https://localhost:5001/redirect";
|
||||
#else
|
||||
public const string REDIRECT_URI = "https://qboauth.ayanova.com/redirect";
|
||||
#endif
|
||||
|
||||
public const string DISCOVERY_DOCUMENT_URL = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration";
|
||||
|
||||
//current 2019 fall disco doc urls
|
||||
@@ -67,7 +74,7 @@ namespace qbridge.Controllers
|
||||
|
||||
|
||||
|
||||
[HttpGet("Start/{qboid}")]
|
||||
[HttpGet("start/{qboid}")]
|
||||
public async Task<IActionResult> GetAsync([FromRoute]string qboid)
|
||||
{
|
||||
|
||||
@@ -82,7 +89,7 @@ namespace qbridge.Controllers
|
||||
if (DiscoveryDoc == null)
|
||||
{
|
||||
return Content($"<h1>Error - Unable to fetch Discovery document from QuickBooks Online</h1>Cannot proceed");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -120,13 +127,19 @@ namespace qbridge.Controllers
|
||||
|
||||
// Redirect endpoint
|
||||
//Step 4 here: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/openid-connect
|
||||
[HttpGet]
|
||||
[HttpGet("redirect")]
|
||||
public async Task<IActionResult> GetAsync([FromQuery]string state, [FromQuery]string code, [FromQuery]string realmId)
|
||||
{
|
||||
//NOTE: state is our own state provided in the initial auth redirect
|
||||
//code is authorization code used to then get the refresh and access token
|
||||
//realmId is the id of the actual company database to work with chosen by user on login
|
||||
|
||||
if (DiscoveryDoc == null)
|
||||
{
|
||||
return Content($"<h1>Error - Unable to fetch Discovery document from QuickBooks Online</h1>Cannot proceed with Revoke");
|
||||
}
|
||||
|
||||
|
||||
//We arrive here after the user has logged in and now we should have the authorization code that can now be used to fetch the actual tokens we need
|
||||
var TokenEndpoint = DiscoveryDoc["token_endpoint"].Value<string>();
|
||||
if (string.IsNullOrWhiteSpace(TokenEndpoint))
|
||||
@@ -221,7 +234,7 @@ namespace qbridge.Controllers
|
||||
{
|
||||
DiscoveryDoc = null;
|
||||
}
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user