This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -36,7 +36,7 @@
|
|||||||
//"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
|
//"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
|
||||||
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#specifying-the-browsers-url
|
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#specifying-the-browsers-url
|
||||||
"pattern": "^\\s*Now listening on:\\s+http://\\S+:([0-9]+)",
|
"pattern": "^\\s*Now listening on:\\s+http://\\S+:([0-9]+)",
|
||||||
"uriFormat": "http://localhost:%s/qbridge/"
|
"uriFormat": "http://localhost:%s/start/"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|||||||
@@ -10,14 +10,21 @@ using System.Net.Http.Formatting;
|
|||||||
|
|
||||||
namespace qbridge.Controllers
|
namespace qbridge.Controllers
|
||||||
{
|
{
|
||||||
[Route("[controller]")]
|
//[Route("[controller]")]
|
||||||
|
[Route("")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public class OAuthRedirectController : ControllerBase
|
public class OAuthRedirectController : ControllerBase
|
||||||
{
|
{
|
||||||
public const string CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
|
public const string CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
|
||||||
public const string CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
|
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";
|
public const string DISCOVERY_DOCUMENT_URL = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration";
|
||||||
|
|
||||||
//current 2019 fall disco doc urls
|
//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)
|
public async Task<IActionResult> GetAsync([FromRoute]string qboid)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -82,7 +89,7 @@ namespace qbridge.Controllers
|
|||||||
if (DiscoveryDoc == null)
|
if (DiscoveryDoc == null)
|
||||||
{
|
{
|
||||||
return Content($"<h1>Error - Unable to fetch Discovery document from QuickBooks Online</h1>Cannot proceed");
|
return Content($"<h1>Error - Unable to fetch Discovery document from QuickBooks Online</h1>Cannot proceed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,13 +127,19 @@ namespace qbridge.Controllers
|
|||||||
|
|
||||||
// Redirect endpoint
|
// Redirect endpoint
|
||||||
//Step 4 here: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/openid-connect
|
//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)
|
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
|
//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
|
//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
|
//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
|
//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>();
|
var TokenEndpoint = DiscoveryDoc["token_endpoint"].Value<string>();
|
||||||
if (string.IsNullOrWhiteSpace(TokenEndpoint))
|
if (string.IsNullOrWhiteSpace(TokenEndpoint))
|
||||||
@@ -221,7 +234,7 @@ namespace qbridge.Controllers
|
|||||||
{
|
{
|
||||||
DiscoveryDoc = null;
|
DiscoveryDoc = null;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,64 +18,64 @@ namespace qbridge.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
// [HttpGet]
|
||||||
public ContentResult Index()
|
// public ContentResult Index()
|
||||||
{
|
// {
|
||||||
var errorBlock = string.Empty;
|
// var errorBlock = string.Empty;
|
||||||
|
|
||||||
var resp = $@"<html lang=""en"">
|
// var resp = $@"<html lang=""en"">
|
||||||
<head>
|
// <head>
|
||||||
<meta charset=""utf-8"">
|
// <meta charset=""utf-8"">
|
||||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1, shrink-to-fit=no"">
|
// <meta name=""viewport"" content=""width=device-width, initial-scale=1, shrink-to-fit=no"">
|
||||||
<title>AyaNova QBOI bridge authorization server</title>
|
// <title>AyaNova QBOI bridge authorization server</title>
|
||||||
<script src=/jquery-1.9.1.js></script>
|
// <script src=/jquery-1.9.1.js></script>
|
||||||
|
|
||||||
</head>
|
// </head>
|
||||||
<body >
|
// <body >
|
||||||
|
|
||||||
<div style=""text-align: center;"">
|
// <div style=""text-align: center;"">
|
||||||
{errorBlock}
|
// {errorBlock}
|
||||||
<div style=""display: inline-block;text-align:left;"">
|
// <div style=""display: inline-block;text-align:left;"">
|
||||||
<h1>QBOI Bridge</h1>
|
// <h1>QBOI Bridge</h1>
|
||||||
|
|
||||||
<form action=""/QBridge"" method=""post"">
|
// <form action=""/QBridge"" method=""post"">
|
||||||
<div class=""container"">
|
// <div class=""container"">
|
||||||
<div>
|
// <div>
|
||||||
<label for=""uname""><b>User name</b></label>
|
// <label for=""uname""><b>User name</b></label>
|
||||||
<input type=""text"" placeholder=""Enter Username"" id=""uname"" name=""uname"" required>
|
// <input type=""text"" placeholder=""Enter Username"" id=""uname"" name=""uname"" required>
|
||||||
</div>
|
// </div>
|
||||||
<br/>
|
// <br/>
|
||||||
<div>
|
// <div>
|
||||||
<label for=""pwd""><b>Password</b></label>
|
// <label for=""pwd""><b>Password</b></label>
|
||||||
<input type=""password"" placeholder=""Enter Password"" id=""pwd"" name=""pwd"" required>
|
// <input type=""password"" placeholder=""Enter Password"" id=""pwd"" name=""pwd"" required>
|
||||||
</div>
|
// </div>
|
||||||
<br/>
|
// <br/>
|
||||||
<div>
|
// <div>
|
||||||
<button type=""submit"">Login</button>
|
// <button type=""submit"">Login</button>
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
</form>
|
// </form>
|
||||||
|
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
</body>
|
// </body>
|
||||||
</html>";
|
// </html>";
|
||||||
|
|
||||||
|
|
||||||
return new ContentResult
|
// return new ContentResult
|
||||||
{
|
// {
|
||||||
ContentType = "text/html",
|
// ContentType = "text/html",
|
||||||
StatusCode = 200,
|
// StatusCode = 200,
|
||||||
Content = resp
|
// Content = resp
|
||||||
};
|
// };
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
[HttpPost]
|
// [HttpPost]
|
||||||
public IActionResult Index([FromForm]string uname,[FromForm]string pwd)
|
// public IActionResult Index([FromForm]string uname,[FromForm]string pwd)
|
||||||
{
|
// {
|
||||||
return Content($"Uname: {uname}, Password: {pwd}");
|
// return Content($"Uname: {uname}, Password: {pwd}");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// public class CBUserModel
|
// public class CBUserModel
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace qbridge
|
|||||||
|
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args)
|
WebHost.CreateDefaultBuilder(args)
|
||||||
|
.UseUrls("http://*:3003")
|
||||||
.UseStartup<Startup>();
|
.UseStartup<Startup>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:57520",
|
"applicationUrl": "http://localhost:3003",
|
||||||
"sslPort": 44391
|
"sslPort": 44391
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "api/values",
|
"launchUrl": "api/values",
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
"applicationUrl": "https://localhost:3003;http://localhost:3003",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user