What I’m trying to do:
Prior to loading the rest of my application to users, I want to authenticate/verify them via the built-in Google Auth service (then allow the rest of the application to load in. If user is not logged in or is not on the “approved” user list (separately managed)), I want to throw an “Unauthorized” exception). For added context, this is being performed on a locally-run version of the runtime app server.
What I’ve tried and what’s not working:
Everything up to and including the session auth with Google succeeds. User opens the web-page, gets prompted with a Google Login form via anvil.google.auth.login(). My application successfully authenticates the request with google, but never manages to exit the login() call.
The runtime server logs:
[TRACE anvil.runtime.server] CB: Session <session_token> → app
[DEBUG anvil.runtime.server] CLIENT AUTH COMPLETE
[TRACE anvil.runtime.server] {<the user’s informaation, access token, email, etc.>}
Then nothing else. The app does not load my pages/forms; It does not even get to the next line to print the results. I have tried both putting the login() step within the MainForm template init__components() step, as well as trying in the init of the MainForm, but both provide the same behaviour.
Code Sample:
import anvil.google.auth
from _template import MainFormTemplate
class MainForm(MainFormTemplate):
def __init__(self, **properties):
# login
email_addr = anvil.google.auth.login()
print(f"User logged in as {email_addr}")
# /login
# Set Form properties and Data Bindings.
self.init_components(**properties)
Note: The “User logged in as {email_addr}” print never occurs, which is why I suggest it never escapes the anvil.google.auth.login() call. I dug a little into the runtime server code and found the location where this operation occurs, but I am way out of my depth when it comes to Clojure: anvil-runtime/server/core/src/anvil/runtime/server.clj at master · anvil-works/anvil-runtime · GitHub (line 899).
EDIT: Line number