I’ve gotten it to work. @RGJ helpfully pointed the following out:
When discourse does the redirect and sends the API key to be decoded as a payload in the redirect url, that key goes through url encoding. So to get the actual API key, you need to do URL decoding on the payload. The result is the properly working API key (which matches the length of the key that discourse prints on the screen).
I have provided the steps that I follow to get this to work here: