I want to use QZ API as a stand alone API, which I can consume from my windows service as per scheduling. Can I do that?
I have explored this and found that right now only with HTML Page (browser) I can use this, If somebody help me out then it would be great.
For this If I have to buy the paid version that is fine for me.
--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bad Base64 input character '34' in array position 0, this is only happening when I am making the requests from our C# library.
"signature": "TWFuIGlzIGRpc..."
"signature": { "response": "TWFuIGlzIGRpc..." }
--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/4f127171-a80a-4e20-945f-afc784587a89o%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "qz-print" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qz-print/MmFO6Xo_5aE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/CANQs7dBnE5BQDC9B%2BN1tjWt4HC2oXT0bgAcW-k8_2h%2B490gtNA%40mail.gmail.com.
public static string BuildHash(string request )
{
//Encode request to create the message we wil be signing
using (SHA256 toHash = SHA256.Create())
{
byte[] bytes = toHash.ComputeHash(Encoding.UTF8.GetBytes(request));
StringBuilder message = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
message.Append(bytes[i].ToString("x2"));
}
return message.ToString();
}
}
public async Task<string> Signing(string msgTosign)
{
var values = new Dictionary<string, string>
{
{ "message", msgTosign},
{ "apiKey", localApiKey } //apiKey for internal validation/security
};
HttpContent content = new StringContent(values.ToJson(), System.Text.Encoding.UTF8, "application/json");
var response = await client.PostAsync(signingUrl, content);
return await response.Content.ReadAsStringAsync();
//current output example: "hPMxT/veLXCMv6FXXtjBRyhNVzYKrjbz0KiVEHhT2xwqPjgOiE0wIGh0jRm3+UAibdMkAfU5TdyIfO5c7Qac8f6gHTk+4TbVkG9y7cOGtMMZ6N3dwvI5m/xgudaQehGJGW1A/6i0VwCq19NnPMp9LPfVjg/y+1b1KkKHkZudWA6taekdqRCvn9AIOCv66kfp48rN5W81XOf9HZkyup6QsgA9G6kkX6ht+PTmOVwJadIiwNh7JelYVQBFKMDaxJW3DHrxBWRdHdvPAWp9VJP5pFWpYaQ9XAa8hbfHQl/XsIHrCIrCPBzQsvqOH5gBR3Dk5AsYZUMByuicLfvKTM1ANA=="
}
//include signature into request object
var signature = await qzClient.Signing(hashed);
defaultPrinter.Signature = signature;
// send command to socket:
await ws.SendString(defaultPrinter.ToJson(), cancellationToken);
// Send command to socket task:
Task SendString(this ClientWebSocket ws, string defaultPrinter, CancellationToken cancellation)
{
var encoded = Encoding.UTF8.GetBytes(defaultPrinter);
var buffer = new ArraySegment<byte>(encoded, 0, encoded.Length);
return ws.SendAsync(buffer, WebSocketMessageType.Text, true, cancellation);
}
Hello Pablo, Tres,Indeed we have a C# implementation similar to what you are doing.I was hoping to share it with you today after work but my laptop has crashed today. I have arranged to have it fixed tomorrow, so the moment I have my environment restored, I will share with you the approach we took.But Tres is right, it is mostly likely related to serialization.Kind regardsMartin
On Tue, 30 Jun 2020, 17:26 Tres Finocchiaro <tres.fi...@gmail.com> wrote:
Bad Base64 input character '34' in array position 0, this is only happening when I am making the requests from our C# library.I haven't authored a C# wrapper (and we don't officially support this), but I've had a lot of experience with the base64 signatures and have a YouTube tutorial which covers how we came up with our C# signing examples: https://www.youtube.com/watch?v=u3XcvAEWvEIAnyway, the best way to tackle this is to just read the console logs from QZ Tray: https://qz.io/wiki/faq#console-logsThere's a good chance the base64 is getting serialized (e.g. JSON) or something. Looking at the data should help understand why it can't be decoded. Note, it's quite easy to unserialize it using JavaScript (e.g. $.ajax, fetch) but when you're talking directly to the Java websocket, you don't have the same luxuries and it will have to be a plain/text string.For example:Good:"signature": "TWFuIGlzIGRpc..."Bad:"signature": { "response": "TWFuIGlzIGRpc..." }
To unsubscribe from this group and stop receiving emails from it, send an email to qz-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/4f127171-a80a-4e20-945f-afc784587a89o%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "qz-print" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qz-print/MmFO6Xo_5aE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qz-p...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/8efc9660-85a7-43b4-9b01-2e5a8250f32co%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/CANQs7dAu95GQHC9_j09dLm_sUsfcRJAsuHvhsqe6Rmi8pc5UOg%40mail.gmail.com.
Hi Pablo,I have managed to retrieve the code I mentioned. Please take a look at the attached file.It is the class specifically addressing signing.
On Wed, Jul 1, 2020 at 7:45 PM Tres Finocchiaro <tres.fi...@gmail.com> wrote:
\u0022 is a double-quote character, it looks like the base64 is being wrapped in double-quotes.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/8efc9660-85a7-43b4-9b01-2e5a8250f32co%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "qz-print" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qz-print/MmFO6Xo_5aE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qz-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/CANQs7dAu95GQHC9_j09dLm_sUsfcRJAsuHvhsqe6Rmi8pc5UOg%40mail.gmail.com.
To unsubscribe from this group and all its topics, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/7bb781b3-946e-45a7-a7c2-96604daa86a2o%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/fae727e9-53ab-44a2-b4c2-577903e15106o%40googlegroups.com.