This commit is contained in:
2019-10-01 22:57:50 +00:00
parent 94a8cc1946
commit 5fea7abf83

View File

@@ -339,13 +339,15 @@ namespace AyaNova.PlugIn.QBOI
// }
public static UInt64 RandomUint64()
//Note, always returns a positive number, it's plenty random
public static Int64 RandomInt64()
{
using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
{
var buffer = new byte[sizeof(UInt64)];
var buffer = new byte[sizeof(Int64)];
rng.GetBytes(buffer);
return BitConverter.ToUInt64(buffer, 0);
return Math.Abs(BitConverter.ToInt64(buffer, 0));
}
}
@@ -368,15 +370,18 @@ namespace AyaNova.PlugIn.QBOI
static public void StartAuthorization()
{
//used to tie this session to the auth key on our server for fetching later
QBOI2_SESSION_TOKEN = RandomSessionToken();
QBOI2_SESSION_TOKEN = RandomInt64().ToString();
//shell out to browser for user to login to QB
System.Diagnostics.Process.Start("https://qboauth.ayanova.com/start/" + QBOI2_SESSION_TOKEN);
//LOOP over and over every 5 seconds checking repeatedly for the state token to get off the server or until user selects quit in some dialog that needs to be shown here
//If user selects cancel then just exit qboi
System.Diagnostics.Process.Start("https://qboauth.ayanova.com/start/" + System.Uri.EscapeDataString(QBOI2_SESSION_TOKEN));
//When token found at server under this session token id then fetch it and continue on from here
//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
//NOTE: this app will handle refreshing the token in-session as apparently that's possible from here, maybe should test that or could simply just refresh via our server
Intuit.Ipp.OAuth2PlatformClient.OAuth2Client oac = new OAuth2Client(Q2_CLIENT_ID, Q2_CLIENT_SECRET, Q2_REDIRECT_URL, Q2_ENVIRONMENT);