OAuth2 Callback Error

Hi @david2

I’m glad you were able to demonstrate that the URL works manually. My guess is that you’re not able to test the OAuth flow in the Anvil Editor because the page is in an iframe, so you have been visiting the URL of your app to test it in a new tab. This is entirely reasonable, but have you also published an older version of your app? If so, that old version will load when you visit your app via its published URL, so you won’t see updates from your latest changes. Try publishing the latest version of your app (or unpublishing it entirely) and everything should work!

I would also recommend switching to the Beta Editor, which will let you run your app in a new tab. That way, you can debug without needing to think about publishing your app at all.

Finally, a small hint for JS integration: These days, you can redirect straight from Python using the anvil.js module. In particular, you can do something like:

from anvil.js import window

# Then, later:
def form_show(self, **event_args):
    window.location.href = anvil.server.call('get_oauth_redirect_url')

I hope this helps!

2 Likes