0

Create Form

by
Published Mar 25, 2024

Creates a new Google Form. [See the documentation](https://developers.google.com/forms/api/reference/rest/v1/forms/create)

Script gforms Verified

The script

Submitted by hugo697 Bun
Verified 398 days ago
1
import google from '@googleapis/forms'
2

3
type Gforms = {
4
	token: string
5
}
6

7
export async function main(resource: Gforms, title: string) {
8
	// setup auth
9
	const auth = new google.auth.OAuth2({})
10
	auth.setCredentials({
11
		access_token: resource.token
12
	})
13

14
	const forms = google.forms({
15
		version: 'v1',
16
		auth: auth
17
	})
18

19
	// create new form
20
	const newForm = {
21
		info: {
22
			title: title
23
		}
24
	}
25

26
	const res = await forms.forms.create({
27
		requestBody: newForm
28
	})
29

30
	return res.data
31
}
32