Could not retrieve app files from Google Error

Sooo… I’ve been trying to build a custom multi user sign up / sign in flow starting from this template project: https://anvil.works/build#clone:TTLCYBO7UWVCSTWL%3DT37TCLU5COZYUZ2WONZ7RKXU

The forked project I currently have is here:
https://anvil.works/build#clone:GHYFKQOFMOPHPT5Q=BZ4PLKUTP3JCYZC2PW2QD3SD

The problem I’m getting is when I try and complete the “Sign Up” flow:

I tried looking for “refresh_token” in the app, but could not find it… any ideas?

You need to sign in with your Google account. Go to the Google API under Services and click ‘Enable Email’. You’ll get the Google SSO screen.

This example was written before we had the Email Service - you may wish to modify the example to use the Email Service to send emails instead. Just enable the Email Service and replace google.mail.send with anvil.email.send (NB: if you’re on the Free Plan, stick to GMail - the Email Service sends all outgoing emails to you on the Free Plan).

Thanks for letting us know about this, it’s not explained properly in the relevant section of the docs (Integrations/Google/GMail) so I’ll improve that, and consider improving the error message too.

Thank you so much for this response! I I didn’t see google.email.send, but there is a google.mail.send in the original version. I changed over to the Email Service because I do have a paid plan, change the call to anvil.email.send, and it works like a charm!

1 Like

I’m implementing the custom signup flow in an app I’m developing and I’m getting an error relating to the app origin. Is this because I have not published the app to a custom domain?

anvil.server.InternalError: Could not retrieve app files from Google. Try renewing your app file permissions in the Anvil IDE. (invalid_request; Missing required parameter: refresh_token) at /libanvil/anvil/_threaded_server.py, 
line 362 called from /libanvil/anvil/server.py, 
line 38 called from /libanvil/anvil/google/mail.py, 
line 29 called from custom_signup/ServerModule1.py, 
line 50 called from custom_signup/ServerModule1.py, 
line 90 called from app/custom_signup/login_flow.py, 
line 69 column 10 called from [Navigation, line 38]

The lines reference the emails that should be sent out. Here is the relevant section from ServerModule1 in my custom signup flow app.

@anvil.server.callable
def _send_password_reset(email):
  """Send a password reset email to the specified user"""
  user = app_tables.users.get(email=email)
  if user is not None:
    user['link_key'] = mk_token()
    google.mail.send(to=user['email'], subject="Нууц үгээ дахин сэргээх хэрэгтэй", text="""
Hi,

Someone has requested a password reset for your account. If this wasn't you, just delete this email.
If you do want to reset your password, click here:

%s#?email=%s&pwreset=%s

Thanks!
""" % (anvil.server.get_app_origin('published'), url_encode(user['email']), url_encode(user['link_key'])))
    return True

If it helps I can setup a custom mail server as a work around until I get the domain.

Hi @robert, it should all work fine once you’ve enabled Email under the Google Service. Please let me know if you have any issues.

I’m in the process of updating the writeup to make this step clearer :slight_smile:

Aha thank you! That did the trick!

1 Like