@mart
Thanks for the detailed repro steps. I just looked through the code and didn't see anything that indicated this behavior.
Could you do one more test for me, please? Can you check and see what happens if you don't use FUSIONAUTH_APPLICATION_CLIENT_SECRET and instead use a different variable name? Something like MY_COOL_APPLICATION_CLIENT_SECRET or something like that?
I don't think there's a collision or reserved variable, but it's worth ruling out.
Also, what version of FusionAuth are you running?