Yes! It is completely legal. The codes are given by the developer itself, hence they are legal to use. So, without any hesitation you can use the codes and redeem the rewards.