Google app_files and Anvil app server

Hi.

I am attempting to run a working app cloned with git to a stand alone server.
It uses app_files from Google Drive.
When I launch it I get the following in the console.

[ERROR anvil.dispatcher.native-rpc-handlers.util] Internal server error: 995404782e28
java.lang.UnsupportedOperationException: Attempted to decrypt an encrypted value (‘google-service/delegation-refresh-token’) from the anvil.works hosted platform. This should be specified in the App Server configuration instead.

Could anyone please clarify what is happening and what should be specified in the App Server configuration instead?

Thanks.

Hi @gnu_B,

It turns out this is actually a missing feature in the App Server! Summary: There’s a workaround, which I describe below, and we’ll add the official solution to the next release of the App Server.

Background: In order to use App Files with your app, we must of course provide credentials that allow your app to access your Google Drive to retrieve them. This comes in the form of an OAuth Refresh Token. When you use the Anvil Editor, Anvil obtains a Refresh Token and embeds it (encrypted) into your app. If you want to use App Files with the App Server, you’ll need to acquire your own Refresh Token (using your own Google Client ID and Secret).

As of version 1.8.0 of the App Server, you can’t provide a Refresh Token in your server configuration (command line or config file). However, you can provide one in your anvil.yaml, by editing the Google service’s server_config and adding the key delegation_refresh_token: "<YOUR TOKEN HERE>".

This is a workaround, as this app will not work if you push this change back up into the Anvil platform (Anvil will attempt to use your refresh token with Anvil’s Client ID, which wont’ work). So, in the next version of the App Server, there will be a --google-refresh-token configuration variable for setting this value without editing your anvil.yaml.

1 Like

Hi meredydd.
Thank you for your response. I hope to try this in the following days and hope to be able to mark this as the solution, for anyone else who finds them selves in the same situation.
Keep up the great work and have a good weekend.

Hi meredydd.

After setting up AOuth as in the documentation ‘Connecting Google to Anvil’ and verifying everhing works,

I tried your suggestion, and continue to get the same error message.

Should the refresh token be encrypted by any means, before it is stored under the delegation_refresh_token key?

1 Like

Hi , I also tried this solution but not working.