This commit is contained in:
2019-10-01 22:10:14 +00:00
parent df942c859b
commit a1a1c67657

View File

@@ -298,7 +298,7 @@ namespace AyaNova.PlugIn.QBOI
const string Q2_CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
const string Q2_REDIRECT_URL = "https://qboauth.ayanova.com/redirect";
const string Q2_ENVIRONMENT = "Sandbox";
static string QBOI2_SESSION_TOKEN = "";
//simple xor encryption
@@ -339,6 +339,25 @@ namespace AyaNova.PlugIn.QBOI
// }
public static UInt64 RandomUint64()
{
using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
{
var buffer = new byte[sizeof(UInt64)];
rng.GetBytes(buffer);
return BitConverter.ToUInt64(buffer, 0);
}
}
public static string RandomSessionToken()
{
using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
{
var buffer = new byte[sizeof(UInt64)];
rng.GetBytes(buffer);
return Convert.ToBase64String(buffer);
}
}
static ServiceContext SC = null;
@@ -348,9 +367,19 @@ namespace AyaNova.PlugIn.QBOI
//then test that all ops work witha fresh company connection
static public void StartAuthorization()
{
//used to tie this session to the auth key on our server for fetching later
QBOI2_SESSION_TOKEN = RandomSessionToken();
System.Diagnostics.Process.Start("https://qboauth.ayanova.com/start/" + QBOI2_SESSION_TOKEN);
//here we need to loop checking for the data we need on qboauth site or quit if user selects quit so
//a special dialog is required here or something
Intuit.Ipp.OAuth2PlatformClient.OAuth2Client oac = new OAuth2Client(Q2_CLIENT_ID, Q2_CLIENT_SECRET, Q2_REDIRECT_URL, Q2_ENVIRONMENT);
Intuit.Ipp.OAuth2PlatformClient.OAuth2Client oac = new OAuth2Client(Q2_CLIENT_ID,Q2_CLIENT_SECRET,Q2_REDIRECT_URL, Q2_ENVIRONMENT);
//case 3669
//https://help.developer.intuit.com/s/question/0D50f00005gFeqpCAC/how-do-i-suddenly-get-there-was-an-error-while-communicating-with-the-ids-server
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
@@ -362,42 +391,42 @@ namespace AyaNova.PlugIn.QBOI
Intuit.Ipp.Security.OAuth2RequestValidator validator = new Intuit.Ipp.Security.OAuth2RequestValidator(ACCESS_TOKEN);
SC = new Intuit.Ipp.Core.ServiceContext(REALM_ID, Intuit.Ipp.Core.IntuitServicesType.QBO, validator);
SC.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
SC.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
SC.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = "c:\\temp\\qblogs\\";
SC.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = "c:\\temp\\qblogs\\";
//' Common setting for both ServiceContexts:
SC.IppConfiguration.MinorVersion.Qbo = "23";
//' Common setting for both ServiceContexts:
SC.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
SC.IppConfiguration.MinorVersion.Qbo = "23";
//' Serialization Format Json or xml
SC.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
SC.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
//' Serialization Format Json or xml
SC.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
SC.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
SC.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
//' Compression Format can be GZip or Deflate:
SC.IppConfiguration.Message.Request.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
SC.IppConfiguration.Message.Response.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
//' Compression Format can be GZip or Deflate:
//' Retry 5 times at an interval of 1 Second if service fails. Note that RetryPolicy moved from Intuit.Ipp.Retry to Intuit.Ipp.Core.
SC.IppConfiguration.Message.Request.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
TimeSpan retryInterval = new TimeSpan(0, 0, 0, 1);
SC.IppConfiguration.Message.Response.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Core.IntuitRetryPolicy(5, retryInterval);
//' Retry 5 times at an interval of 1 Second if service fails. Note that RetryPolicy moved from Intuit.Ipp.Retry to Intuit.Ipp.Core.
//' For data updates, create DataService:
TimeSpan retryInterval = new TimeSpan(0, 0, 0, 1);
Intuit.Ipp.DataService.DataService loDataService = new Intuit.Ipp.DataService.DataService(SC);
_AuthenticationCompleted=true;
SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Core.IntuitRetryPolicy(5, retryInterval);
//' For data updates, create DataService:
Intuit.Ipp.DataService.DataService loDataService = new Intuit.Ipp.DataService.DataService(SC);
_AuthenticationCompleted = true;
}