Hey @Gsmplus! Thanks for reaching out and for your patience - I was hoping to get a response out sooner.
I think the key to unblocking you here is understanding how to correctly reference these "magic" variables. That's not an official name, but I call them as such because they are automatically detected and replaced by the Retool backend without needing the double curly braces.
In your first example, that would mean referencing your stored variable as VAR_REFRESH instead of {{ VAR_REFRESH }}. You would need to use a similar pattern if you end up using the native OAuth2 (Generic) block in your custom authentication flow.
I hope that helps! Let me know if you have any additional questions.
Have you had a chance to review this, @Gsmplus? Hopefully the above is helpful, as I'm pretty sure it address the primary cause of the errors you were seeing.