Os guias de início rápido explicam como configurar e executar um app que chama uma API do Google Workspace. Este guia de início rápido usa uma abordagem de autenticação simplificada adequada para um ambiente de teste. Para um ambiente de produção, recomendamos aprender sobre autenticação e autorização antes de escolher as credenciais de acesso adequadas para seu app.
No Apps Script, os inícios rápidos do Google Workspace usam os Serviços avançados do Google para chamar as APIs do Google Workspace e processar alguns detalhes do fluxo de autenticação e autorização.
/** * Prints the title of the sample document: * https://docs.google.com/document/d/195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE/edit * @see https://developers.google.com/docs/api/reference/rest/v1/documents/get */functionprintDocTitle(){constdocumentId='195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE';constdoc=Docs.Documents.get(documentId,{'includeTabsContent':true});console.log(`The title of the doc is: ${doc.title}`);}
Clique em Salvar .
Clique em Projeto sem título, digite Quickstart e clique em Renomear.
Configurar o script
Ativar a API Google Docs
Abra o projeto do Apps Script.
Clique em Editorcode.
Ao lado de Serviços, clique em Adicionar um serviço add .
Selecione API Google Docs e clique em Adicionar.
Executar a amostra
No editor do Apps Script, clique em Executar.
Na primeira vez que você executar a amostra, será necessário autorizar o acesso:
Clique em Revisar permissões.
Escolha uma conta.
Clique em Permitir.
O registro de execução do script aparece na parte de baixo da janela.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-01 UTC."],[],[],null,["Create a\n[Google Apps Script](/apps-script/overview)\nthat makes requests to the Google Docs API.\n\nQuickstarts explain how to set up and run an app that calls a\nGoogle Workspace API. This quickstart uses a\nsimplified authentication approach that is appropriate for a testing\nenvironment. For a production environment, we recommend learning about\n[authentication and authorization](/workspace/guides/auth-overview)\nbefore\n[choosing the access credentials](/workspace/guides/create-credentials#choose_the_access_credential_that_is_right_for_you)\nthat are appropriate for your app.\n\nIn Apps Script, Google Workspace\nquickstarts use\n[Advanced Google services](/apps-script/guides/services/advanced) to call\nGoogle Workspace APIs and handle some details of the authentication\nand authorization flow.\n\nObjectives\n\n- Configure the environment.\n- Create and configure the script.\n- Run the script.\n\nPrerequisites\n\n- A Google Account\n\n\u003c!-- --\u003e\n\n- Access to Google Drive\n\nCreate the script\n\n1. Create a new script by going to [script.google.com/create](https://script.google.com/create).\n2. Replace the contents of the script editor with the following code:\n\n\ndocs/quickstart/quickstart.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/docs/quickstart/quickstart.gs) \n\n```javascript\n/**\n * Prints the title of the sample document:\n * https://docs.google.com/document/d/195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE/edit\n * @see https://developers.google.com/docs/api/reference/rest/v1/documents/get\n */\nfunction printDocTitle() {\n const documentId = '195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE';\n const doc = Docs.Documents.get(documentId, {'includeTabsContent': true});\n console.log(`The title of the doc is: ${doc.title}`);\n}\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n3. Click Save .\n4. Click **Untitled project** , type **Quickstart** , and click **Rename**.\n\n\u003cbr /\u003e\n\nConfigure the script\n\nEnable the Google Docs API\n\nOpen the Apps Script project.\n\n1. Click **Editor** code.\n2. Next to **Services** , click Add a service add .\n3. Select Google Docs API and click **Add**.\n\nRun the sample\n\nIn the Apps Script editor, click **Run**.\n\nThe first time you run the sample, it prompts you to authorize access:\n\n1. Click **Review permissions**.\n2. Choose an account.\n3. Click **Allow**.\n\nThe script's execution log appears at the bottom of the window. \ndone It worked! **Great!** Check out the further reading section below to learn more.\nwarning There was a problem **Bummer** , [let us know what went wrong](#). Check out our [troubleshooting](#troubleshooting) section below for some common errors and solutions. If you have found a bug in the code, [report the issue on GitHub](https://github.com/googleworkspace/apps-script-samples/issues) or submit a pull request.\n\nNext steps\n\n- [Google Apps Script Advanced Services documentation](/apps-script/guides/services/advanced)\n- [Troubleshoot authentication and authorization issues](/workspace/docs/api/troubleshoot-authentication-authorization)\n- [Docs API reference documentation](/workspace/docs/api/reference/rest)"]]