Woocommerce linked licensing system for your plugins
-
@matt_sf I use
Server.setHttpHeader("Authorization: Bearer " + token);
Console.print() your
text
variable to make sure it contains what you think it does. -
@d-healey here's a snippet, the "text" variable contains only the token as a string.
If I use a the token as a string I get a "Wrong number of segments" error.
If I use the token as an object I get a "Signature verification failed" error...HiseSnippet 1336.3ocsWstaaaCElJIpn1adXEaO.B5WxXN9RaV2PJ1lqykUilKd0osa+piVhNlIxjBjTw0MH.6QaOR6MX6PQcytNYAFs5OIj7b467cNjmiGH39DojKPVUNadDAY8k1CmyTS1aBlxP82GY8M1CIhqHh8vggNW0tYmlOA0adDVJIAHKqM+UsfVU1Bk78O+RObHl4SJ1BgdCm5SNhNkpJ1cP2WRCCODGPNiNsjz6zsuOmsGOjGCfZS61nHr+k3yImf0hsgMx5AGDPUbwPEVQjHqs5wClObBeFyH+anR5nPhdQGzPvPlsOjGFnQrdWzdSngACxBdIBrxfBpXSCU7s1GSCn46WPIecxANEZTlOr1XQ3s4BvqSY30tD7VAjrJAosLP5Q1C8EzHUwIZ77E18YJhXLFn8xPwHKZCmGXuGGjfoZNEeI4PArHWCum1tcCmG2tc8mUqZsp.4KUNWgENgiBesjHX.u67SNYF3bhZO9zHNCV34VRFWs9Kn8..Hy3hf6R6LYbMdWPN2IFLHnRISqUyyUQduJQLsP5fzHTlEVRnLrPX9h4QJJm8RxbPiNO9I6jCz.h7REOB19PZHY3bohLUamjZEgWoM22HYQLRYi4fdoVHIvzIPsJdt5CapxQh4BTSIQ0CKIu9UG44NQohj61pkjGyBFSYmSDxl97otKmE.vUq500pVwMNin2MghZ3n2LJi+1MgRpU8lD8orPJi3LNl4qCcGNqmhMjvBzIBAOzyOKKz.7RXLotwIgbeLbKGBLkPWaHHRPLIo9ybfOskqPG63koRkqcR+f+uRZXBVH7sT0jAmN7LO2Vyh19BIm05hYpswwpIstpSKE+RBysgSTibH5Ig6KwxFN4tzojs0+457+qRB+NSPUjSGcAwWkiylIVVygFAgvUxCIMiDTcA2qREyYWGWmua4XzDjk73MYgckaxH1UWHOxPtt0043TJV+d4H3oKuk495OKwRqJIA14MDAc77+mzzh4.M2aRb5peH2kPOgbbvykCUPjetWBirLabllqxnBPybZqnd8EPY5KHX8kA2mCIOtf9ArFr65zifEvE0xJun5225fVPjPCfGKgBBW26phHqPnR5+n+VLlLYTih0yimaStRY9hL98JaaxR2V9d4zX8zDdoL8Ibn1k4Uu50UqT8lpNKez3wq7rTCFB4iUcrtUp3tTziEOcj9sCS0SlfP+kEaZYe6MsJ2S02vOkDjy5ynpSiHraqSKJkT0M3RQEHpJo81Wk1dqWrRwYHZft2VNahR.c4AKPut+9XENyTfUAOEQDJpNHr1mbEL3goyYE6zmvgXMOWByRbqNthc5sZz6Kb4ezcd9ht+YWI9JRe1.nNhnLLBUdLeJXYrXdFAT3rGZbVsTmcDdDILwW0rK0sqr+Noj+P62UeQCvrs98ezLZfZRwoztSHzymTZDqet6XfTFR+PINqc26Ofx5rda.5u9sT.U0NqMzmBP8f6UsPAl96YKlTLX5g1oB9wYjOdrJXfNdPbHVs3Td5QaSO.tEsvnU5wmXRpZd4Qe+jM528EhOxd.U4OY0XbiUfQ3lxmCLlNvbM6CFOFZGW.vsrO72+7LcL5U7XEzZ6XLzgCJFrOId5P32L3S.uyXjP8qXVaneuwrtsdslAz2oSV7uvW5gczqsROrS1gnoXeA+c9lWozij+vjc.LkbQEdi3X8ZmNYOMYa2tYazT3WG7Neec3uMTusZcd7ZnySVCc1YMz46WCcd5ZnyOrF57i2oN5eXFLnBep45.rwfCRZQXYc.CCUVIUgn+CjFkKIA
Also a weird thing : when I get the token then ask for validation and get a header error, if I start again from the beginning, I don't receive the token and get a 403 error... I don't know if it's supposed to happend serverwise...
-
@matt_sf I'm getting
403
when clicking btnSend -
@d-healey ... sorry it was a generic snippet, here I put some test credentials :
HiseSnippet 1361.3ocsWs0aaaCElJIJnxadXEa6cA8jLVpuz10Mjhs45bYMnMIdwIoaO0QKQGyFYRARp35FDf8Sa+j1+fsCE0M65jE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sCS0StfP+k4aZYe6Msp1SMvvOUDjyNfQUGGSX2VmVTFopavkgJPTUZ6suHq8VuDkhyPzPcusB1DkB5pCVfN6fcwJbto.qBdJlHTTcPXsK4JXvCSmSG6rmvgXsHWByRbqN1wN6VM58kt726NqXQ2+nqDeE4.VenNhnLLBUdHeBXYrXVNAT5rGXbV8Lm8Z7PRTpupaWoaWU+cTE+g1sq9hldDM4nlPZR0DX4ozP03RYncGSnWLtxfV+T2Q.0Lf9gJLW6tUgkycBq79q2Fr9yeMCVeictnmBX6EAAPqM0phuz8Tyzkb0Jr6bj4l2qRlRP+WSmO2Y.8CryD7iSbe7zWvbe7vjHrZ9gA0S.mc.bYatIvzSYwjT0rpSH++1Dh2WH9P69TUv3kiw0VBFgKTeJvX1b00s2azHnqcI.2vd+e6SyPznS3IJnC3gXnQHTLXeTxjAvOsHf.dmwHQ5G6rVS+rjYca8ZMCnu5mt3efurC6nWakcXm7CQSvAB9aCLOlomb+Ao6.XJ89L7Txg50tcxeAy1tcy1nIvOh3sAA5v+QP81x04wqfNOYEz4oqfNe2JnyyVAc99UPme3N0Q+62f4Y3SLWGfM5uWZmDKq8XXnxJsJD8uPIY6vM
-
@matt_sf Mystery solved. Look in your info.txt file, see those quotation marks? They're not part of your token are they :)
Try
local text = info.loadAsString().replace('""');
-
@d-healey aaaarrh, I sensed they might be the cause of the error, I tried to use
.replace
but didn't write it correctly.
Thanks a lot David, as always you're here to save the day -
@d-healey I tried it this morning but no luck, the
.replace
function didn't work, I still ended up with the quotation marks...
But I tried different things and ended up writing the whole response object (not just the token) to a file and load it as anobject.value
and it finally worked.HiseSnippet 1368.3ocsWs0aaaCElJIpnxadXEa6cA8jLVpuz10Mjhs45bYMnMod0oYaO0QKQGyFYRARp35FDf8Sa+j1+fsyQWrjcbRKLV8KQj7b467cNjmS5qjALsVpHVNmLKlQr9b6AyDlw6NlxEjC2iX8U1CXpKXpcoQQtWztYmlOjzaVLUqYgDKqM+ETPKmsHo+9metGMhJBXkaQH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pCdPd8g6QMzBSAVE7TLSY3XPXsG6BXvjrNqN14OwCw57bILqwM5XG67K8j2U5x+n6r4K59mc0zKXGJ5C0QLSFiv0GIm.VlplUP.kN6tYNqdtydAcHKJ0W0sqzMrp+Nth+H60EuQiivoG0DRSll.KOkGZFWJCu6XF+rwUFD6m5NBnlA72Wg4Z2sJrbtUXUz+8lf0e8q4v5arKD8D.aOMH.Z8YVW7ktmYFVxUatcWfLuyGUISIn+6oKl6x.8csyE75ItqOcFLWnLLIhZVbXQbB47CfKaKLgFNElPyMypNA8+aSP9wBw6Y2maBFuZLtwJvHbg5SAFym6tt89iFAMsJA3V1G76eZFxl7JYhAF+5HpQwghA6iSlL.9WOBXf2EBVD9Xm0F3yRYqaiqQF.u5mt3ege4G1AWakeXmhCISnAJ4aBxdLCmr+to6.XJ89L7TxQ3Z2NEufYa2tYaxD3ex3MAAX3eenda057f0PmGtF57n0PmuaMz4wqgNe+ZnyObq5f++cv.MxIYWGfM5ueZmDKq8ETnxJsJj7efpnPjI
Edit : I tried just this little bit of code and the
.replace
function doesn't work as expected...? :const text = '"text"'; Console.print(text.replace('""'));
Console prints :
"text"
-
HiseSnippet 685.3ocsU0taSCCE0tsdhV9bR7.D0e0JMpZgw.oIDi0OfJXaUjwD+axywc0ZN1QNNiUg3cl2.35jrkVnTFQh7ijd+33bx8dt2NwnY73XsAgqe77HNBeOh+bkcV+YTgBMd.B+.xAzXK23k4Z+4Qz3Xd.Biq9VmCb8Znzqu+58oRphwKbgPmnEL9GDgBag2I68dgTNhFvOVDtP1au2XlV0WK0I.epR5hhnrKnmyOj5RqBAg2XXfvpM9VpkGiv01WGL2el9Kpr7OQDKNSxcF8P9vAk4djVF3XryKp+LgLXx0e2wH3TlTTEplUEdL4.Qf3F+EUiGkFvq.wh0CbkkoW0knWu+D8VAkvKPoZYTZShOyHhrEQb74tjwJn4LkBk8EoRVtnJODS5qgLT1NgzK3iLfwMHZsS2ta4A2ZuaiFPoO15Y4WY8dkWS2ylfW.brVx6DYDJaKm2NFdjzAtoKks7ZNi68NsbtWHkQgiWzrc6cmlnXVgV4oUGps7iTsZ23qMp23aM790PSmtxXNVazRI2rxvNkiYc.aoRBOia1x6RpLgeShP4b4dzF2tdDKqHtPhZ0XkvdTDO2d8hLTdW.90mFOfZotlbtOHuHtwJbzAOfeILwj0xqSFviuvpifYleSO.JQcPhjZWVd5lIyC.0ikzDt9tJVXmu3L6+fls6Z0r2VJtIYhvxlsZNVYEbDpT+O3X9j98ICmNkyrEDrFYzmK6X8e40+QchUnN+.p0HtBgIGlD5CK6Xb3sqTbIb3DbEmZIytqy1UA74pfTie.W4A64rw4A6ccPDLFZzmxxlBb6RtSpGfSpz0n0g84fsWOT5jAfizsSWTHrV6TFy84+DP.uZLOsDXdVIvrcIv77RfYmRf4Ek.yKWKF2+n7lDqNLab.bLYX5JBLdnhBJqTUH5mbvmDj.
-
@matt_sf Console always shows quotation marks for strings. I tested the code before I suggested it to you with your snippet and it worked for me.
-
@d-healey @ustk oh that's odd.
@matt_sf said in Woocommerce linked licensing system for your plugins:
const text = '"text"';
Console.print(text.replace('""'));
Ok in this example I put the
"string"
inside the simple quotes'
so that was my mistake.But If I use a txtFile.txt containing
"Some text"
(with the double quotes like I get when writing theresponse.token
into a file) and use this code:const desktop = FileSystem.getFolder(FileSystem.Desktop); const textFile = desktop.getChildFile("txtFile.txt"); const test = "test"; Console.print(test.replace('""')); Console.print(textFile.loadAsString().replace('""'));
It doesn't work. The console output correctly
test
but outputs"Some text"
...HiseSnippet 741.3ocsU01aSCCD1tsdhVXHlD+.h5WVpznpEFCjlPrs9BpB1VEYLw2l7bbWslicThyXUH9yvuP9G.mSxVRGkxnRjOzz64tG6Ge9tKiizLdbrNBgqexrPNB+Hh2LkYZuoTgBMpOB+XxgzXCOxIC5fYgz3XtOBiq9NK.tdMT5yOd6ATIUw3EPHzoZAi+AQfvTfNdu2KjxgTe9IhfRQu8diXZUOsTm.5oJoCJjxtjdA+HpMrJDDdsA9BiNxyPM7XDt1AZ+YdS0eQkE+ohXw4Rt0nKxCVnL3gZouUwVTTuoBo+3aN2wHXUFWjEplkEdJ4Pgu3V7hrwSRc3Tvnb9.WYd4UcN408OIuEHIbIIUKSRaP7XQhPSgGqddHYjBtblPgzdYojEKpx2wjdZHBkoc.8R9vHv3VFt6zoyVNvOs1sQCH0Gab74wWZzgNuwYnPx8lA27AsufaRSgQtk.6mEYqcWOmpgesw5G3luJVhomMKraSSl+1v6lE6HjoL.kl12MATPtwZHpvHgx3ZQaGwCkV4tYyla1BXd2PxWWol5uermAPuvs0cYMIQwLBsxQqNRa3Gqba03qMp23aMbtqqISVnOahLRKkPdXQtsEyQKinqJI3bdzVNWQkI7aCDtgmurYs6WYCK6dsTfZ0HkvbbHO2d408n7BC3eeZTepgZq6xwf3B4QFgUN397qfl3rpv5j76cnM92JQglCsehjZluiwNlH2AjOlqL0VJphElYkGi7OzF0YosQ2WItAYrvvltXMVYAZDxT+OzX9vm0IClLgyLEBrFY3mW0IM+ks+i5DCzubHEZatFgIGkD3AyeYbX2UJtDVbBthsZIyti01lA73J+TieBO4N6Zsw4N6diST.kEoOik0EXGu8fTDPSpzI60gOw.1NcQocF.ORm1cPAvj1yXL6w+YPA7h477UfyKVANauBbd4JvYmUfyqVANudobreja+DiNHqc..FOHcDAFOPQgJqzpPzuvoOTjw
The other answer would be that I'm totally losing It (which wouldn't be impossible) :face_with_tears_of_joy:
-
@d-healey said in Woocommerce linked licensing system for your plugins:
I tested the code before I suggested it to you with your snippet and it worked for me.
I thought so, that's why I was surprised it didn't work here....
-
Try below snippet. By the way, why are you using replace? For removing spaces? If yes, you should use it like this:
textFile.loadAsString().replace(" ", "")
HiseSnippet 738.3ocsU0taSCCE0tqAQKTDShGfn7qToQUJLFHgPrs9ApB1VEYLw+l7bbWslicThyXUHdt30h2.353rkrQ2zTkVpTS84dOtmb84dyzTEkkkoRQ3VGtHggvO0IbgTOevbBWhlLDgelydjLMK00Bs6hDRVFKBgwq8IC.tUSTw0e93tDAQRYUPHzQJNk8EdLWWgNc6OyEhwjH1g73ZYu41SnJ4.kPkC5YMm.TBgdF4T19DSZMbP3GMJhqUogZhlkgvM2UEsHbt5GRa9Gwy3mHXlE8QgvFYgGqDQFEaPQClyEQSu74NCA6xzppvZ1pvKb1iGwuBupZ77h.tULpWOvMtK40ut7Bt+xCWSdMsxacmPZJOQWEwnsm3LQBGTyHvQPcYYyE032XmNsGnfbj5dwjyXiSgEWwweqffMbgu599Ns6zFNJxztQrryzpD2O3NlKXgK.mPbuSY5BMm5WCbnMSCYKUM6BsINvsbWLDKd9Lv9dZa7dvcu5+mPsSCj7L28JvAQmofLSR4RsuAuWJKQXDsm2FtddcM7uYVkauPQh1IKTCnm52cYDselkKoZtR5pj6qzrCj9ca+y1sZ+q1t2LzrYKMlo1lpDBnvrrvF2d5cQzWlGeBKcC2yIhb1UIBG6W2W4b69p51dp8ntVhJ4DIWePBSdatMTo+.902lLjnIFCXIFjWBKUyMR.OjcNzYasisbJO7gd6+yqBcLpnbAQe81Hyrix.PM3Z9UiiTlw0KpOa4Ao259J20clx0z4KWuMVhdgp1CsdKmT0wYzrYLptRrMcF+8G9wRnupx0PG0dDnw5BvStedbHL3lx.kHkLgwmhaXbT10Al0lJSHSFUr3uvUYv9l03xf8uLHJlPSUGSscGlYgOt.Azjr3UBsf2MAqc6iJ5X.dNA8BPwvH5ioTSo3kf1WNmWsBbd8JvYyUfyaVANasBbd6Jv4c2IGyaG2IWqhssI.vzQEiQv3QRB3xJbjn+Q023zw
-
@orange said in Woocommerce linked licensing system for your plugins:
For removing spaces?
No, we're removing quotation marks
""
-
@d-healey said in Woocommerce linked licensing system for your plugins:
No, we're removing quotation marks ""
Why? I think there is no need to do that?
-
@orange When the token is written to the text file it adds quotation marks. These need to be removed before being added to the header.
-
@d-healey Then substring can work here. This will extract the string between first and last chars.
exampleString.substring(1, exampleString.length-1);
-
@d-healey @orange so,
.substring
works but.replace
doesn't...
(no matter if I write.replace("", "")
or.replace('""', "")
the result is the same).By using this, I mananged to get it to work :
const info = desktop.getChildFile("info.txt"); // Function getTheToken info.writeObject(response); // Function verifyTheToken local text = info.loadAsObject(); local token = text.token; Server.setHttpHeader("Authorization: Bearer " + token);
Is there a preferred method between
.loadAsObject()
and.loadAsString
for these kind of things or is there no difference ? -
@matt_sf I use an encrypted object.
-
@matt_sf said in Woocommerce linked licensing system for your plugins:
Is there a preferred method between .loadAsObject() and .loadAsString for these kind of things or is there no difference ?
I think objects would be better choice. Writing and Rreading encrypted objects is more secure way for that purpose. You can encrypt the file with a combination of complex pin and machine ID. Also you can change the encrypted file extension from .json to .dat or whatever you like.
-