HMAC is sort of hash algorithms (it counts something like CRC code for provided message but on cryptographic basis). HMAC counts hash value of the message and uses key for it. The purpose of it is to prove that the hash has been counted only by someone who knows the key and nobody else.
HMAC mismatch error can be caused by many reasons:
- You use wrong HMAC algorithm. In your code you use HMAC SHA1 but there are many of them
- You use good HMAC algorithm but wrong HMAC parameters. HMAC algorithm has typically several parameters like length, chaining mode,...
- You use wrong message formatting. There might be some kind of message formatting rules before you count HMAC.
- you use wrong key.