Once you've installed this extension, make sure to grant it permission to write to your spreadsheet. Follow these steps:
- Find the account name for the installed extension in the Service accounts section. The name will look something like
ext-{extension-instance-id}@{project-id}.iam.gserviceaccount.com
. - Open the spreadsheet file you want to share. You must be the owner or have edit access to the spreadsheet.
- Click the "Share" button.
- Enter the extension account name found in step 1 and grant it write permission.
- Click "Send".
Using the extension is really easy. Send a request to https://${LOCATION}-${PROJECT_ID}.cloudfunctions.net/ext-${EXT_INSTANCE_ID}-saveRecord
to see them in your spreadsheet immediately.
If the ALLOWED_FIELDS parameter is set, only the keys of the body request that match the allowed fields will be saved in the spreadsheet. If all fields are allowed, everything sent in the body request will be saved.
const url = `https://${LOCATION}-${PROJECT_ID}.cloudfunctions.net/ext-${EXT_INSTANCE_ID}-saveRecord`;
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Firebase-AppCheck': appCheckTokenResponse.token, // Required if App Check is enabled. Learn More: https://firebase.google.com/docs/app-check/web/custom-resource
},
body: JSON.stringify({
name: 'John Due',
phoneNumber: '+123456789',
email: '[email protected]',
age: 23,
isCustomer: true,
}),
});
const json = await response.json();
As a best practice, you can monitor the activity of your installed extension, including checks on its health, usage, and logs.