양식 작성자가 응답할 수 있는 사용자를 더 세부적으로 관리할 수 있도록 응답자에 대한 세부적인 관리 기능이 도입됩니다. 2026년 1월 31일 이후에 API로 만든 양식은 기본적으로 게시되지 않은 상태입니다. 자세한 내용은
Google Forms API 변경사항을 참고하세요.
Apps Script 샘플 웹 앱
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지에서는 Google Forms API의 Apps Script 웹 앱 예시를 간략히 설명합니다.
기본 요건
- Google Cloud 프로젝트에서 Forms API를 사용 설정합니다.
- 샘플 웹 앱의 GitHub README 파일에 설명된 대로 새 Apps Script 프로젝트를 설정합니다.
개요
Forms API를 사용하면 인증된 모든 클라이언트가 REST를 사용하여 API에 직접 액세스할 수 있습니다.
Apps Script는 유효한 OAuth 액세스 토큰을 가져오고 REST를 호출하는 간단한 방법을 제공하므로 Apps Script를 Forms API와 직접 통합하는 것이 쉽습니다.
Apps Script는 이미 스크립트가 Google Forms를 만들고, 액세스하고, 수정할 수 있는 기존 Forms 서비스를 제공합니다. 하지만 Apps Script에서 직접 Forms API를 사용하려면 다음과 같이 OAuth 액세스를 설정하세요.
범위가 지정되고 인증된 OAuth 액세스 토큰을 가져옵니다.
ScriptApp.getOAuthToken();
API에 대한 모든 REST 호출에 제공된 options 인수에 OAuth 토큰을 포함합니다.
UrlFetchApp.fetch(Url, options);
이 작업의 예는 Apps Script 프로젝트 설정을 참고하세요. 설정 가이드에서는 API를 호출하는 데 필요한 기본적인 배관을 자세히 설명합니다. 하지만 최종 사용자에게 API에 대한 직관적인 액세스를 제공하려면 샘플 웹 앱을 사용해 보고 수정해 보세요.
웹 앱 사용 예시
모든 Forms API 메서드를 직접 호출하는 전체 웹 앱 예시는 데모 목적으로 GitHub에서 확인할 수 있습니다.
웹 앱 실행
프로젝트를 설정하고 웹 앱으로 배포한 후에는 몇 가지 기본 작업을 시도해 볼 수 있습니다.
양식 만들기 버튼을 클릭하여 새 양식을 만듭니다.
이제 새 양식이 양식 ID: 필드에 표시되며 Forms에서 열기를 클릭하여 열 수 있습니다.
새 양식을 별도의 창에서 연 후 몇 가지 질문을 직접 추가해 보세요. 그런 다음 Get Form by Id를 클릭하면 오른쪽의 JSON 출력에 새 질문이 표시됩니다.
앱에서 사용할 수 있는 다른 메서드를 자유롭게 살펴보고 각 작업의 오른쪽에 있는 출력을 확인하세요.
Forms 시계 작업
양식 시계의 버튼도 확인합니다. 이러한 함수는 Forms API 보기 기능을 사용하고 보기를 만들고, 나열하고, 삭제하고, 갱신하는 기본 작업을 실행합니다. 이를 사용하려면 Cloud Pub/Sub 주제가 있는 프로젝트를 설정해야 합니다.
Forms API 보기 및 Cloud Pub/Sub에 관한 자세한 내용은 푸시 알림 설정 및 수신을 참고하세요.
다음 단계
필요에 맞게 예시 앱을 맞춤설정해 보세요. 예를 들면 다음과 같습니다.
- Google 시트에 문제 은행을 만든 다음 Apps Script SpreadsheetApp 서비스를 사용하여 시트에서 질문을 가져와 새 양식을 채웁니다.
- 또는 질문 자료가 SQL 데이터베이스에 있을 수 있으며, 이 경우 Apps Script JDBC 서비스를 사용하여 데이터베이스의 질문으로 양식을 채울 수 있습니다.
- 퀴즈를 생성하고 Google 시트 성적부에 점수를 저장합니다.
- Cloud Pub/Sub으로 프로젝트를 설정하고 시청 기능을 사용하여 실시간 학생 리더보드를 생성하여 퀴즈 결과를 표시합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-04-09(UTC)
[null,null,["최종 업데이트: 2025-04-09(UTC)"],[],["This content details using Apps Script with the Google Forms API. Key actions include enabling the Forms API and setting up an Apps Script project. It demonstrates obtaining an OAuth access token via `ScriptApp.getOAuthToken()` and making REST calls with `UrlFetchApp.fetch()`. A web app example allows users to create forms, view them by ID, and interact with API methods. Additionally, it highlights the use of Forms API watches with Cloud Pub/Sub for creating, listing, deleting, and renewing watches. The app can be customized to suit specific needs.\n"],null,["# Apps Script sample web app\n\nThis page provides an overview of the Apps Script web app example for the\nGoogle Forms API.\n\nPrerequisites\n-------------\n\n- Enable the Forms API in your Google Cloud project.\n- Set up a new Apps Script project as described in the [GitHub README file](https://github.com/googleworkspace/apps-script-samples/blob/main/forms-api/demos/AppsScriptFormsAPIWebApp/README.md) for the sample web app.\n\nOverview\n--------\n\nThe Forms API allows any authenticated client to access the API\ndirectly using [REST](https://www.codecademy.com/article/what-is-rest).\n\nBecause Apps Script provides an easy way to obtain both a valid\n[OAuth Access Token](https://oauth.net/2/access-tokens/) and make REST calls,\nit's straightforward to integrate Apps Script directly with the Forms API.\nApps Script already provides an existing\n[Forms Service](/apps-script/reference/forms), which allows scripts to create,\naccess, and modify Google Forms. However, if you prefer to use the\nForms API directly from Apps Script, set up OAuth access as follows:\n\n1. Get a scoped and authenticated OAuth access token.\n\n `ScriptApp.getOAuthToken();`\n2. Include the OAuth token in the *options* argument provided in any REST\n calls to the API.\n\n `UrlFetchApp.fetch(Url, options);`\n\nSee\n[Set up an Apps Script project](/workspace/forms/api/guides/forms-apps-script)\nfor an example of this in action. The setup guide details the basic plumbing\nneeded to call the API---however, to provide intuitive access to the API for\nend users, you can also try out and modify our sample web app.\n\nWeb app example usage\n---------------------\n\nA complete example web app that calls all of the Forms API methods directly\nis available on\n[GitHub](https://github.com/googleworkspace/apps-script-samples/tree/main/forms-api/demos/AppsScriptFormsAPIWebApp)\nfor demonstration purposes.\n\n### Running the web app\n\nOnce you've set up your project and deployed it as a Web app, you can try some\nbasic operations.\n\n1. Create a new form by clicking the **Create Form** button.\n\n The new form is now visible in the **Form id:** field and you can open it by\n clicking **Open in Forms**.\n2. After opening the new form in a separate window, try adding a few questions\n manually, then click **Get Form by Id** and you'll see your new questions\n in the JSON output on the right.\n\nFeel free to explore the other methods available in the app and observe the\noutput on the right for each operation.\n\n### Working with Forms watches\n\nNotice also the buttons for forms\n[watches](/workspace/forms/api/reference/rest/v1/forms.watches). These use the\nForms API watches feature and perform basic operations to\ncreate, list, delete and renew watches. You need to set up a project with\n[Cloud Pub/Sub](https://cloud.google.com/pubsub) topics to use them.\n\nFor more information on Forms API watches and Cloud Pub/Sub, see\n[Set up and receive push notifications](/workspace/forms/api/guides/push-notifications).\n\nNext steps\n----------\n\nTry customizing the example app to suit your needs. Here are a few examples:\n\n- Create a *question bank* in a Google sheet, and then use the Apps Script [SpreadsheetApp](/apps-script/reference/spreadsheet/spreadsheet-app) service to fetch questions from a sheet to populate new forms.\n- Alternatively, your question bank can reside in a SQL database where you can use the Apps Script [JDBC Service](/apps-script/reference/jdbc) to populate forms with questions from the database.\n- Generate a quiz and save the scores in a Google sheet grade book.\n- Set up your project with Cloud Pub/Sub and use the [watches](/workspace/forms/api/guides/push-notifications) feature to generate a real-time student leaderboard to display quiz results."]]