How to use Google Forms and other APIs easily from FileMaker using Google Service Account

Teruhiro Komaki(Archive)
frudens Tech Blog
Published in
5 min readApr 19, 2022
Photo by Pawel Czerwinski on Unsplash

Hello.

I am Teruhiro Komaki for frudens Inc.

In our previous blog, we explained Google authentication.

In this blog, as the title suggests, we will explain how to easily use Google’s API using Google Service Account.

Configure Google Cloud Platform settings

Register and login to Google Cloud Platform.

Create a project.

Google Cloud Platforms.

The project has been created.

Google Cloud Platforms.

Configure settings to use the API.

Click “Menu > APIs & Services > Credentials” .

Click “CREATE CLEDENTIALS > Service account”.

Create a service account.

Click on the Service account you created.

Click “KEYS > ADD KEY > Create new key”.

Click “CREATE”.

A JSON file will be downloaded.

Click “Menu > APIs & Services > Library”.

Search for “forms” and click on “Forms”.

Click “ENABLE”.

Forms API is enabled.

Google Cloud Platform configuration is complete.

Case 1: Purchase of learning materials

Learning materials are available for sale on Shopify. If you are interested, you can purchase them at the following URL

Learning materials for using Google Service Account from FileMaker

Open the file “frudens_google_serviceAccount.fmp12” in FileMaker.

Click “Goto Service Account”.

Click “New Record”.

Insert the JSON file downloaded earlier.

Check the API documentation to enter the Scope.

Copy “https://www.googleapis.com/auth/forms.body.readonly".

Copy “https://www.googleapis.com/auth/forms.responses.readonly".

Paste into “Scope”.

https://www.googleapis.com/auth/forms.body.readonly https://www.googleapis.com/auth/forms.responses.readonly

Note that they are separated by spaces.

Click “Get AccessToken”.

AccessToken has been obtained.

Copy “ClientEmail”.

For testing purposes, access Google Drive and create Google Forms.

Click “Add collaborators”.

Add the ClientEmail you just copied to the collaborator.

Copy the formId in the URL.

Open the file “frudens_google_forms_api.fmp12” in FileMaker.

Paste in “formId”.

Click “Request”.

The API was successfully requested. It is very easy.

Case 2: Develop your own

Check Google documentation.

Click “HTTP/REST”.

Step1: Create “{Base64url encoded header}”.

Base64URLEncode the following JSON

{"alg":"RS256","typ":"JWT"}

The following steps will result in the same value as the documented result.

Step2: Create “{Base64url encoded claim set}”.

Create the same JSON as in the sample.

{
"iss": "761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com",
"scope": "https://www.googleapis.com/auth/devstorage.read_only",
"aud": "https://oauth2.googleapis.com/token",
"exp": 1328554385,
"iat": 1328550785
}

Step3: Create “assertion”.

Step4: request “access token”.

Make the request with curl as per the documentation.

AccessToken has been obtained.

The AccessToken obtained allows access to resources that have been configured for sharing.

Next time

Next, we will explain how to use GmailAPI with “OAuth 2.0 client”.

If you have a request, please feel free to contact us on Twitter etc.

--

--