Fetching forms from Google Drive

Using medic-conf to obtain form files stored in Google Drive

To work collaboratively on form design it can be helpful to keep XLSForms in Google Drive. The fetch-forms-from-google-drive action downloads these XLSForms so that they can be converted to XForms and uploaded to your CHT app.

This action requires the following files in the top-level folder of your CHT app config: forms-on-google-drive.json and .gdrive.secrets.json.

forms-on-google-drive.json

This JSON file contains key value pairs, where the key is the relative path and name for the downloaded file, and the value is the file’s Google Drive File ID.

To get the File ID for the form open the form in Google Sheets. The URL will look something like https://docs.google.com/spreadsheets/d/12345ABCDEF/edit#gid=555666888 . The ID is the middle portion 12345ABCDEF

{
  "app/sample_report.xlsx": "12345ABCDEF",
  "contact/person-create.xlsx": "ABCDEF123456",
}

.gdrive.secrets.json

This file contains authentication secrets that are generated by enabling access to your Google Drive using these instructions.

{
		"client_id": "your_client_id",
		"project_id": "your_project_id",
		"auth_uri": "https://accounts.google.com/o/oauth2/auth",
		"token_uri": "https://accounts.google.com/o/oauth2/token",
		"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
		"client_secret": "your_client_secret",
		"redirect_uris": ["your_redirect_uris", "http://localhost"]
}

Run

With the files in place, run medic-conf’s fetch-forms-from-google-drive action in your CHT app’s top level directory.

medic-conf fetch-forms-from-google-drive

You will be prompted for an access code from your authenticated user. Follow the prompts through Google’s authentication page and copy the access code into your command line. The forms will then be downloaded to the locations set in the forms-on-google-drive.json file.


CHT Applications > Quick Guides > Forms

Managing and using forms in the CHT