I got intermittent InvalidSignature when i connect...
# suitescript
d
I got intermittent InvalidSignature when i connect to NS using Oauth 1.0, any ideas what cause this ?
b
this is a failure to encode the oauth parameters as described in the oauth 1.0 rfc
d
the call to the restlet is every 10 seconds, it's randomly failing
for example 1st call ok, 2nd call ok, 3rd fail
b
there are 64 characters used in the base64 encoded signature
compare which characters are present in successful signatures against failed signatures
once you figure out which character that is, revisit what the bot, or what i am telling you
d
correct me if i'm wrong but my 2nd hit will have different nonce and timestamp, so for sure the 64chars will be different with the 1st one ?
b
its the different characters used in the encoding, (the alphabet) that you want to be comparing
you dont care about the actual value
its the characters used in the value
d
sorry so it's not the signature that i have to compare ?
i'm still kinda blur
b
one of the letters in your signature is causing you errors
figure out which one it is
d
for example this is what postman generated
Copy code
myHeaders.append("Authorization", "OAuth realm=\"9387927\",oauth_consumer_key=\"xxx\",oauth_token=\"zzz\",oauth_signature_method=\"HMAC-SHA256\",oauth_timestamp=\"1715743844\",oauth_nonce=\"7FZxJmxNZTi\",oauth_version=\"1.0\",oauth_signature=\"gHGMy4gDgkX6w81C4kDC3vhZjzFZ%2BAQIQA9YxpI7j7E%3D\"");
you're saying to compare the successfull
oauth_signature
with the failed one ?
b
which letters are used in the signature you shared
d
i'm using postman for the above, the 3rd party vendor ( i don't have their code ) built their own script to connect to Netsuite
b
the likely answer is that they are failing to encode the signature
to prove it, you find out which letters are used in successful signatures and compare it to the letters in failed signatures
the failed signature will have letters not used in the successful ones
d
acutally i don't really understand what do you mean by 'letters', but i will check with the vendor. Or do you have sample 'letters' to be used to encode/generate signature ?
b
which letters are present in the string: 'HGMy4gDg'
the more normal name is character set, but i had no luck using characters with you earlier
d
using my above example in postman, this is the generated valid signature
gHGMy4gDgkX6w81C4kDC3vhZjzFZ%2BAQIQA9YxpI7j7E%3D
so i should compare this with the next signature which is not valid, correct ?
b
comparing them does little if you dont actually know what you are comparing
which letters are present in the string: 'HGMy4gDg'
d
yes you're right, actually i still don't quite get it on what should i look in the comparison, but i'm asking vendor on how they generate signature and what 'letters' they use, probably i can get a better understanding
b
can you answer the question: which letters are present in the string: 'HGMy4gDg'
d
ok i will try to ask the vendor
b
you are unlikely to understand where this was going if you cant actually answer the question
d
you mean HGMygDg ?
b
if you gave that answer on a test
you would fail
because you gave g twice
its the same letter
d
so it's HGMygD
b
correct
d
then ?
b
and now we are onto the character part
not actually interested in only letters
you also want numbers and symbols or basically any other character
applied to multiple signatures
So you can find out which characters are used in successful requests and which are used in the failed ones
the spoiler is that there are characters used in the failed ones that are not present in the successful ones
which is where you would prove its not actually random
d
sorry but can you give example, i believe it will be clearer
so you're saying valid signature = ABC1234%xx Invalid = ABC1234d%xx
so i look for 'd' ?
b
yes, but it could be e f g and so on
you need more signatures to figure the whole set of characters
d
so once i found out 'd' is the wrong char, then how to solve it ?
b
which i will tell you is very finite, the sigature is encoded in base 64, which has a character set of 64 characters
once you find out which character it is, you can stop looking at it as a random problem
and what you are not doing to not send that invalid character
which is the response you didnt understand from the bot and my first reponse
d
so battk, if i manage to compare the valid and invalid signature, and i can find out the 'd' , can i tell which parameter is wrong ? like nonce, realm, timestamp, etc. Or by doing comparation you can only determine that it's not random ?
b
there are specific error messages for wrong nonce and timestamp
there is also a specific type of error that you get with a wrong realm
d
ic
b
im assuming the parameters are fine since it works sometimes
d
ic ic
b
its just the one of the steps required to generate a valid oauth authorization header is being done incorrectly
d
my vendor is using this to generate the signature, so i guess it should be valid and consistent https://gist.github.com/ecounysis/7889b67704a26f26369399a636105233
probably it's something else in his code
b
that cant possibly be the code used
its always wrong
it doesnt support hmac-sha256
the normal c# recommendation is https://restsharp.dev/
d
hmm ok
b
if they are doing anything related to it, then it being an encoding issue becomes assured
their example dont encode the oauth parameters