{"id":183649,"date":"2026-05-18T18:03:04","date_gmt":"2026-05-18T09:03:04","guid":{"rendered":"https:\/\/support.questetra.com\/?p=183649"},"modified":"2026-05-18T18:04:47","modified_gmt":"2026-05-18T09:04:47","slug":"service-task-google-drive-filecopy","status":"publish","type":"post","link":"https:\/\/support.questetra.com\/en\/bpmn-icons\/service-task-google-drive-filecopy\/","title":{"rendered":"Google Drive: Copy File"},"content":{"rendered":"\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"58\" data-attachment-id=\"113160\" data-permalink=\"https:\/\/support.questetra.com\/en\/developer-blog\/how-to-use-timer-start-event\/attachment\/advanced-banner-new-en\/\" data-orig-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?fit=1200%2C68&amp;ssl=1\" data-orig-size=\"1200,68\" data-comments-opened=\"0\" data-image-title=\"advanced-banner-new-en\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?fit=1024%2C58&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en-1024x58.png?resize=1024%2C58&#038;ssl=1\" alt=\"\" class=\"wp-image-113160\" srcset=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=1024%2C58&amp;ssl=1 1024w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=600%2C34&amp;ssl=1 600w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=768%2C44&amp;ssl=1 768w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?w=1200&amp;ssl=1 1200w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading has-border-color has-product-main-border-color has-white-color has-product-main-background-color has-text-color has-background has-link-color\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--20)\"><strong>Google Drive: Copy File<\/strong><\/h4>\n\n\n\n<p class=\"has-text-align-right has-border-color has-product-main-border-color has-white-color has-product-main-background-color has-text-color has-background has-link-color has-small-font-size mt-0 pt-0 wp-block-paragraph\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:0;padding-right:var(--wp--preset--spacing--20);padding-bottom:0;padding-left:var(--wp--preset--spacing--20)\"><a href=\"https:\/\/support.questetra.com\/en\/bpmn-icons\/googledrive-filecopy\/\">Google \u30c9\u30e9\u30a4\u30d6: \u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc<\/a><\/p>\n\n\n\n<p class=\"has-border-color has-product-main-border-color has-text-color has-white-background-color has-background has-link-color mt-0 pt-0 wp-block-paragraph\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:var(--wp--preset--spacing--30);margin-left:0;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)\">This item copies the specified file on Google Drive. You can optionally specify the destination folder and the new file name, and store the ID or web view URL of the created file.<\/p>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details open><summary class=\"wp-block-coblocks-accordion-item__title\">Basic Configs<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<dl style=\"0 0 -0.7em 0\">\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #C3C3C3;\"><\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">Step Name<\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #C3C3C3;\"><\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">Note<\/dd>\n<\/dl>\n<\/div><\/details><\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image alignright has-custom-border is-style-default\"><img decoding=\"async\" src=\"data:image\/png;base64,\n        iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA71JREFUWEfF\n        V11oFFcU\/s7M7K6TRs1vK1VUSGmbCK2SB6VFgpLWlYC2omIDLaUlCBGfimwWgw9Fu9mW0ocSoUhE\n        aKmlgUgUyShiEUWSh4AW7L9CS5PGZhuTJmTi7swcmUn3d+ZOdtGy87Ts3HvOd77zfefeIZT5oVLy\n        h2MP3wTMViJqZqABQM1\/+6cIuMvMo4B8RYuGzhUbd0kArT1TK2VWj5CEg2DUFRWYkGALX5ikf3Kl\n        q2bGb48vgJ0x\/T2WEC86cWEmQoIsRIai6mkRCCGAcHy+F0ydRVW81CLik1qk4pDXMk8A4bj+NRhv\n        LRW3pPeEs1pEbXeTVPDPE63clc3NRB4DTs8JfX6V7d2soKVRgizlk5cyGBdvmbj8velLDDHez9VE\n        JoqtdoXU3\/wE19Io452tCtQgUP2Uu3u\/TliInE1CT\/pgICQM1p9LuyMTZUdMP06Eo37wYweC2LhO\n        wsQ0o245QZHzVxsm8O2IgS+vG74sMOPEpajabS\/KAAjH9Um\/6vdvUdD+qoKQAiykgFmdUb\/CzcLE\n        DCN+PoWfxi0xCEJCi6j1GQDOhCNrQLRjdQ2h+40g1tdnE\/4zy6gIkdOO3Mdi4OodE59eTPmbhKU9\n        9sR0IoZj870gsec7tivY1axAkbIxDQuY\/JexaiWBCoiYnmd8fsnAzV98BMl8UotWHHK27uzRhxnY\n        7AX55XUSjrQFULvcTbdNs92G2kr3u1u\/W4h+I1YjASNDXeqWRQZ69EnAe85Hdwew9QXZVeXsAqP3\n        soENayS0bZJR4EpHJ2eupTA4KmQhoXWpi00N9+j2qhyCF7l4\/SUZHdsUVC7Lr9Du87UfTXx8IYW1\n        dYRje4JYXe1m4d7fjI8GkxibYi9yLa1LlYUAbHEd3xdE0xoXLhQqPdchuZlsnZwfNXDqqqct8wC4\n        WlBK0FLA5gDMtsBLhJ+9HcSLz7qrH3\/AmFtgBJR8ym0uQwG4tGJawNBtE\/3D+Szki9DDhrubZbzb\n        EsCyQBaz3wASmX7sAePDgST+SBToINeGokF0Yn8Qm9ZLTlXMwF\/TjKdXuEewKHnSAPpHDHx1w0MD\n        uYPIcYLHKH7leRmHdyioqiCHdltU9u9inx\/+tNDd73E4FY5iO6DoMPqgLYBtTTLuzzBWVZHL7yIw\n        cw8Zfd8Z0G6754DnYSQ6jm2fd74WQMMzhMpQcdXb7br+s4nYoMd5IDqOnZFcxIWkWPpF64QXkvSG\n        sl7JsiDKeCn9X5go9VqeBlHWD5M0iLJ+mhUquSwfp49ru6X2PwLQFL0wM02BagAAAABJRU5ErkJg\n        gg==\n    \" alt=\"Auto Step icon\" class=\"has-border-color has-ast-global-color-4-border-color\" style=\"border-width:0.5em\"\/><\/figure>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details open><summary class=\"wp-block-coblocks-accordion-item__title\">Configs for this Auto Step<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<dl style=\"0 0 -0.7em 0\">\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_Auth<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C1: Service Account Setting<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_SourceFileId<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C2: Source File ID<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_DestinationFolderId<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C3: Folder ID to store (The same folder as the source if blank)<\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_NewFileName<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C4: New File Name (named automatically if blank)<span style=\"color:#000099;\"><sup style=\"font-style:italic;\">#{EL}<\/sup><\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_NewFileIdItem<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C5: Data item to save new File ID<\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_NewFileUrlItem<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C6: Data item to save new File Web View URL<\/dd>\n\n<\/dl>\n<\/div><\/details><\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--30)\"><span>Notes<\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The files that will be downloaded must be shared in advance with the service account set in [C1: Service Account Setting]<\/li>\n\n\n\n<li>To set up [C1: Service Account Setting] :\n<ol class=\"wp-block-list\">\n<li>Prepare a&nbsp;<a href=\"https:\/\/cloud.google.com\/iam\/docs\/service-account-overview?hl=en\" target=\"_blank\" rel=\"noreferrer noopener\">service account<\/a>&nbsp;on Google Cloud Console\n<ul class=\"wp-block-list\">\n<li>Create or upload a&nbsp;<a href=\"https:\/\/cloud.google.com\/iam\/docs\/service-account-creds?hl=en#key-types\" target=\"_blank\" rel=\"noreferrer noopener\">service account key<\/a>\n<ul class=\"wp-block-list\">\n<li>If you&nbsp;<a href=\"https:\/\/cloud.google.com\/iam\/docs\/keys-create-delete?hl=en#creating\" target=\"_blank\" rel=\"noreferrer noopener\">create a service account key on Google Cloud Console<\/a>, you can download a JSON file containing the necessary information<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create an OAuth2 JWT Bearer setting on Questetra BPM Suite and set it to C1\n<ul class=\"wp-block-list\">\n<li>Scope&nbsp;<code>https:\/\/www.googleapis.com\/auth\/drive<\/code>&nbsp;is required<\/li>\n\n\n\n<li>Set up other items as shown in the table below :<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>Settings on Questetra BPM Suite<\/strong><\/th><th><strong>Corresponding Information<\/strong><br><strong>of Google Cloud Service Account Key<\/strong><\/th><th><strong>Property Name in JSON<\/strong>&nbsp;File<\/th><th><strong>Required or Not<\/strong><\/th><\/tr><\/thead><tbody><tr><td>Client ID<\/td><td>OAuth2 Client ID<\/td><td>client_id<\/td><td>Not Required<\/td><\/tr><tr><td>Private Key ID<\/td><td>Key ID<\/td><td>private_key_id<\/td><td>Required<\/td><\/tr><tr><td>Private Key<\/td><td>Private Key<\/td><td>private_key<\/td><td>Required<\/td><\/tr><tr><td>Custom Secret Information 1<\/td><td>Email Address<\/td><td>client_email<\/td><td>Required<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"159853\" data-permalink=\"https:\/\/support.questetra.com\/en\/developer-blog\/markdown-basic\/attachment\/google-drive-auth-setting_capture_en\/\" data-orig-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/04\/google-drive-auth-setting_capture_en.png?fit=1106%2C658&amp;ssl=1\" data-orig-size=\"1106,658\" data-comments-opened=\"0\" data-image-title=\"google-drive-auth-setting_capture_en\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/04\/google-drive-auth-setting_capture_en.png?fit=1024%2C609&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2026\/05\/Google-%E3%83%89%E3%83%A9%E3%82%A4%E3%83%96-%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%B3%E3%83%94%E3%83%BC%E8%A8%AD%E5%AE%9A-en-18_0.png?ssl=1\" alt=\"\" class=\"wp-image-159853\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Errors<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\"code\": 403, \"message\": \"Google Drive API has not been used in project 123456789012 before or it is disabled.\"<\/code>.\n<ul class=\"wp-block-list\">\n<li>&#8216;Google Drive API&#8217; needs to be enabled<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>\"code\": 404, \"message\": \"File not found:\"<\/code>\n<ul class=\"wp-block-list\">\n<li>The file may not exist<\/li>\n\n\n\n<li>&#8216;Google Service Account&#8217; may not have permission to read the file<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--60);text-decoration:underline\">Capture<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border is-style-rounded is-style-rounded--1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"168491\" data-permalink=\"https:\/\/support.questetra.com\/en\/developer-blog\/markdown-basic\/attachment\/google-drive-file-export_capture_en\/\" data-orig-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/google-drive-file-export_capture_en.png?fit=1192%2C1068&amp;ssl=1\" data-orig-size=\"1192,1068\" data-comments-opened=\"0\" data-image-title=\"google-drive-file-export_capture_en\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/google-drive-file-export_capture_en.png?fit=703%2C630&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2026\/05\/Google-%E3%83%89%E3%83%A9%E3%82%A4%E3%83%96-%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%B3%E3%83%94%E3%83%BC-en-18_0.png?ssl=1\" alt=\"\" class=\"has-border-color wp-image-168491\" style=\"border-color:#009900;border-width:3px;border-radius:9px\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--30)\"><span>See also<\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/support.questetra.com\/en\/bpmn-icons\/intermediate-error-catch-event-boundary-type\/\" target=\"_blank\" rel=\"noreferrer noopener\">Intermediate Error Catch Event (Boundary Type)<\/a><\/li>\n<\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details><summary class=\"wp-block-coblocks-accordion-item__title\">Script (click to open)<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<ul class=\"wp-block-list\">\n<li>An XML file that contains the code below is available to download\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/gh-cdn.questetra.net\/Questetra\/Addon-XML\/release-2025-12-15\/google-drive-file-copy.xml\" target=\"_blank\" rel=\"noreferrer noopener\">google-drive-file-copy.xml<\/a> (C) Questetra, Inc. (MIT License)<\/li>\n\n\n\n<li>If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>\nconst COPY_FIELDS = &#39;id,name,parents,webViewLink&#39;;\n\nfunction main() {\n    const auth = configs.getObject(&#39;conf_Auth&#39;);\n    const sourceFileId = getSourceFileId();\n    const destinationFolderId = getDestinationFolderId();\n    const newFileName = getNewFileName();\n    const newFileIdDataDef = configs.getObject(&#39;conf_NewFileIdItem&#39;);\n    const newFileUrlDataDef = configs.getObject(&#39;conf_NewFileUrlItem&#39;);\n\n    const copiedFile = copyFile(auth, sourceFileId, destinationFolderId, newFileName);\n\n    engine.log(`Succeeded to copy. Source ID: ${sourceFileId}, New ID: ${copiedFile.id}`);\n\n    if (newFileIdDataDef !== null) {\n        engine.setData(newFileIdDataDef, copiedFile.id);\n    }\n    if (newFileUrlDataDef !== null) {\n        const webViewUrl = copiedFile.webViewLink ?? `https:\/\/drive.google.com\/file\/d\/${copiedFile.id}\/view`;\n        engine.setData(newFileUrlDataDef, webViewUrl);\n    }\n}\n\n\/**\n * \u30b3\u30d4\u30fc\u5143\u306e\u30d5\u30a1\u30a4\u30eb ID \u3092\u53d6\u5f97\u3059\u308b\n * @return {String} \u30b3\u30d4\u30fc\u5143\u30d5\u30a1\u30a4\u30eb ID\n *\/\nfunction getSourceFileId() {\n    let fileId = configs.get(&#39;conf_SourceFileId&#39;);\n    const fileIdDef = configs.getObject(&#39;conf_SourceFileId&#39;);\n    if (fileIdDef !== null) {\n        fileId = engine.findData(fileIdDef);\n    }\n    if (fileId === null) {\n        throw &quot;Source File ID isn&#39;t set.&quot;;\n    }\n    const trimmed = fileId.trim();\n    if (trimmed === &#39;&#39;) {\n        throw &quot;Source File ID isn&#39;t set.&quot;;\n    }\n    return trimmed;\n}\n\n\/**\n * \u4fdd\u5b58\u5148\u30d5\u30a9\u30eb\u30c0 ID \u3092\u53d6\u5f97\u3059\u308b\uff08\u672a\u6307\u5b9a\u306e\u5834\u5408\u306f\u7a7a\u6587\u5b57\u3092\u8fd4\u3059\uff09\n * @return {String} \u4fdd\u5b58\u5148\u30d5\u30a9\u30eb\u30c0 ID \u307e\u305f\u306f\u7a7a\u6587\u5b57\n *\/\nfunction getDestinationFolderId() {\n    let folderId = configs.get(&#39;conf_DestinationFolderId&#39;);\n    const folderIdDef = configs.getObject(&#39;conf_DestinationFolderId&#39;);\n    if (folderIdDef !== null) {\n        folderId = engine.findData(folderIdDef);\n    }\n    if (folderId === null) {\n        return &#39;&#39;;\n    }\n    return folderId.trim();\n}\n\n\/**\n * \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\u3059\u308b\uff08\u672a\u6307\u5b9a\u306e\u5834\u5408\u306f\u7a7a\u6587\u5b57\u3092\u8fd4\u3059\uff09\n * @return {String} \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u540d\u307e\u305f\u306f\u7a7a\u6587\u5b57\n *\/\nfunction getNewFileName() {\n    const newName = configs.get(&#39;conf_NewFileName&#39;);\n    if (newName === null) {\n        return &#39;&#39;;\n    }\n    return newName.trim();\n}\n\n\/**\n * \u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3059\u308b\n * @param {HttpAuthSettingWrapper} auth \u8a8d\u8a3c\u8a2d\u5b9a\n * @param {String} sourceFileId \u30b3\u30d4\u30fc\u5143\u306e\u30d5\u30a1\u30a4\u30eb ID\n * @param {String} destinationFolderId \u4fdd\u5b58\u5148\u30d5\u30a9\u30eb\u30c0 ID\n * @param {String} newFileName \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u540d\n * @return {Object} \u30b3\u30d4\u30fc\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u60c5\u5831\n *\/\nfunction copyFile(auth, sourceFileId, destinationFolderId, newFileName) {\n    const url = `https:\/\/www.googleapis.com\/drive\/v3\/files\/${encodeURIComponent(sourceFileId)}\/copy`;\n    const body = {};\n    if (destinationFolderId !== &#39;&#39;) {\n        body.parents = [destinationFolderId];\n    }\n    if (newFileName !== &#39;&#39;) {\n        body.name = newFileName;\n    }\n\n    const response = httpClient.begin()\n        .oauth2JwtBearer(auth, () =&gt; getAccessToken(auth))\n        .queryParam(&#39;fields&#39;, COPY_FIELDS)\n        .queryParam(&#39;supportsAllDrives&#39;, &#39;true&#39;)\n        .body(JSON.stringify(body), &#39;application\/json; charset=UTF-8&#39;)\n        .post(url);\n\n    const status = response.getStatusCode();\n    const responseBody = response.getResponseAsString();\n    if (status &gt;= 300) {\n        engine.log(responseBody);\n        throw `Failed to copy. Source ID: ${sourceFileId}, status: ${status}`;\n    }\n\n    let json;\n    try {\n        json = JSON.parse(responseBody);\n    } catch (error) {\n        throw `Failed to parse response. Source ID: ${sourceFileId}`;\n    }\n\n    if (json.id === undefined) {\n        throw `Failed to retrieve new file information. Source ID: ${sourceFileId}`;\n    }\n\n    return json;\n}\n\nconst URL_TOKEN_REQUEST = &#39;https:\/\/oauth2.googleapis.com\/token&#39;;\nconst SCOPE = &#39;https:\/\/www.googleapis.com\/auth\/drive&#39;;\n\n\/**\n * @param {HttpAuthSettingWrapper} auth HTTP \u8a8d\u8a3c\u8a2d\u5b9a\n * @returns {{access_token: string}} \u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u3092\u542b\u3080\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\n *\/\nfunction getAccessToken(auth) {\n    const privateKeyId = auth.getPrivateKeyId();\n    const privateKey = auth.getPrivateKey();\n    const serviceAccount = auth.getCustomSecret1();\n    const scope = auth.getScope();\n    if (!scope.split(&#39; &#39;).includes(SCOPE)) {\n        throw new Error(`Scope ${SCOPE} must be included in the scope.`);\n    }\n    if (privateKeyId === &#39;&#39;) {\n        throw new Error(&#39;Private Key ID is required.&#39;);\n    }\n    if (privateKey === &#39;&#39;) {\n        throw new Error(&#39;Private Key is required.&#39;);\n    }\n    if (serviceAccount === &#39;&#39;) {\n        throw new Error(&#39;Service Account must be set to Custom Secret 1.&#39;);\n    }\n\n    const header = {\n        alg: &#39;RS256&#39;,\n        typ: &#39;at+jwt&#39;,\n        kid: privateKeyId,\n    };\n    const now = Math.floor(Date.now() \/ 1000);\n    const payload = {\n        iss: serviceAccount,\n        aud: URL_TOKEN_REQUEST,\n        sub: &#39;&#39;,\n        iat: now,\n        exp: now + 3600,\n        scope,\n    };\n    const keyB = rsa.readKeyFromPkcs8(privateKey);\n    const assertion = jwt.build(header, payload, keyB);\n\n    const response = httpClient.begin()\n        .formParam(&#39;grant_type&#39;, &#39;urn:ietf:params:oauth:grant-type:jwt-bearer&#39;)\n        .formParam(&#39;assertion&#39;, assertion)\n        .post(URL_TOKEN_REQUEST);\n    const responseText = response.getResponseAsString();\n    if (response.getStatusCode() !== 200) {\n        engine.log(responseText);\n        throw new Error(`Failed to get Access token. status: ${response.getStatusCode()}`);\n    }\n    const result = JSON.parse(responseText);\n    if (result.access_token === undefined) {\n        engine.log(responseText);\n        throw new Error(&#39;Failed to get Access token. access token not found.&#39;);\n    }\n    return result;\n}\n<\/code><\/pre><\/div>\n<\/div><\/details><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This item copies the specified file on Google Drive. You can optionally specify the destination folder and the new file name, and store the ID or web view URL of the created file.<\/p>\n","protected":false},"author":15,"featured_media":168834,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_uag_custom_page_level_css":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[551],"tags":[],"faq_section":[],"class_list":["post-183649","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bpmn-icons"],"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1",1200,675,false],"thumbnail":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=440%2C440&ssl=1",440,440,true],"medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=560%2C315&ssl=1",560,315,true],"medium_large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=768%2C432&ssl=1",768,432,true],"large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1024%2C576&ssl=1",1024,576,true],"1536x1536":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1",1200,675,true],"2048x2048":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-landscape-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-portrait-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=900%2C675&ssl=1",900,675,true],"newspack-article-block-square-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-landscape-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=800%2C600&ssl=1",800,600,true],"newspack-article-block-portrait-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=600%2C675&ssl=1",600,675,true],"newspack-article-block-square-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=800%2C675&ssl=1",800,675,true],"newspack-article-block-landscape-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=600%2C450&ssl=1",600,450,true],"newspack-article-block-portrait-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=450%2C600&ssl=1",450,600,true],"newspack-article-block-square-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=600%2C600&ssl=1",600,600,true],"newspack-article-block-landscape-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=400%2C300&ssl=1",400,300,true],"newspack-article-block-portrait-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=300%2C400&ssl=1",300,400,true],"newspack-article-block-square-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=400%2C400&ssl=1",400,400,true],"newspack-article-block-landscape-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=200%2C150&ssl=1",200,150,true],"newspack-article-block-portrait-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=150%2C200&ssl=1",150,200,true],"newspack-article-block-square-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?resize=200%2C200&ssl=1",200,200,true],"newspack-article-block-uncropped":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1",1200,675,true]},"uagb_author_info":{"display_name":"suesesayaka","author_link":"https:\/\/support.questetra.com\/en\/author\/suesesayaka\/"},"uagb_comment_info":0,"uagb_excerpt":"This item copies the specified file on Google Drive. You can optionally specify the destination folder and the new file name, and store the ID or web view URL of the created file.","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9DiIh-LM5","jetpack-related-posts":[{"id":74763,"url":"https:\/\/support.questetra.com\/en\/developer-blog\/google-drive-items\/","url_meta":{"origin":183649,"position":0},"title":"Utilizing Google Drive from Workflow &#8211; Sending files to people outside the company","author":"Hirotaka NISHI","date":"2020-10-30","format":false,"excerpt":"Google Drive is a cloud storage service offered by Google. I will explain automatic Step for utilizing Google Drive in a Workflow App.","rel":"","context":"In \"Google Drive API v3\"","block_context":{"text":"Google Drive API v3","link":"https:\/\/support.questetra.com\/en\/tag\/google-drive-api-v3\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":76390,"url":"https:\/\/support.questetra.com\/en\/bpmn-icons\/service-task-google-drive-file-upload\/","url_meta":{"origin":183649,"position":1},"title":"Google Drive: File Upload","author":"Hirotaka NISHI","date":"2019-04-23","format":false,"excerpt":"Uploads files specified in File Type Data Item to the specified folder of Google Drive. Capable of obtaining the file ID, the display URL, and the download URL as the response and storing them in a String type Data Item.","rel":"","context":"In &quot;BPMN\u30a2\u30a4\u30b3\u30f3&quot;","block_context":{"text":"BPMN\u30a2\u30a4\u30b3\u30f3","link":"https:\/\/support.questetra.com\/ja\/category\/bpmn-icons\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":82966,"url":"https:\/\/support.questetra.com\/en\/addons\/google-drive-file-convert\/","url_meta":{"origin":183649,"position":2},"title":"Google Drive: File, Convert","author":"IMAMURA, Genichi","date":"2019-12-25","format":false,"excerpt":"Converts file in Google Drive and save as another MimeType file. Supports both Google Doc files and common files. File ID can be obtained from URI etc. (If Folder-ID not specified, the file will inherit any discoverable parents of the source file.)","rel":"","context":"In &quot;Add-ons&quot;","block_context":{"text":"Add-ons","link":"https:\/\/support.questetra.com\/en\/category\/addons\/"},"img":{"alt_text":"Google Drive: File, Convert","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/12\/Google-Drive-File-Convert-en.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/12\/Google-Drive-File-Convert-en.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/12\/Google-Drive-File-Convert-en.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/12\/Google-Drive-File-Convert-en.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/12\/Google-Drive-File-Convert-en.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":67279,"url":"https:\/\/support.questetra.com\/en\/addons\/googledrive-filescopy\/","url_meta":{"origin":183649,"position":3},"title":"Google Drive Files Copy","author":"Hirotaka NISHI","date":"2017-11-26","format":false,"excerpt":"Copies a file on Google Drive and save it to the specified directory. Preparing a file to be a template and it will be a copy automatically at the Start of a new Issue. *Note You need to register Project at Google API Manager beforehand If there is no specified\u2026","rel":"","context":"In &quot;Add-ons&quot;","block_context":{"text":"Add-ons","link":"https:\/\/support.questetra.com\/en\/category\/addons\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2017\/11\/google-drive-file-copy-header.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2017\/11\/google-drive-file-copy-header.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2017\/11\/google-drive-file-copy-header.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2017\/11\/google-drive-file-copy-header.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2017\/11\/google-drive-file-copy-header.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":95817,"url":"https:\/\/support.questetra.com\/en\/addons\/google-drive-file-permissions-remove-anyonewithlink\/","url_meta":{"origin":183649,"position":4},"title":"Google Drive #File_Permissions: Remove AnyoneWithLink","author":"IMAMURA, Genichi","date":"2020-10-06","format":false,"excerpt":"Deletes AnyoneWithLink permission (a Reader permission to anyone who has the link) from the file. There is no change in the other permissions for the file.","rel":"","context":"In &quot;Add-ons&quot;","block_context":{"text":"Add-ons","link":"https:\/\/support.questetra.com\/en\/category\/addons\/"},"img":{"alt_text":"Google Drive: File Permissions, Remove AnyoneWithLink","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Remove-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Remove-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Remove-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Remove-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Remove-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":95834,"url":"https:\/\/support.questetra.com\/en\/addons\/google-drive-file-permissions-add-anyonewithlink\/","url_meta":{"origin":183649,"position":5},"title":"Google Drive #File_Permissions: Add AnyoneWithLink","author":"IMAMURA, Genichi","date":"2020-10-06","format":false,"excerpt":"Creates AnyoneWithLink permission (a Reader permission to anyone who has the link) to the file. Viewers who are notified of the link do not need to sign in to their Google account.","rel":"","context":"In &quot;Add-ons&quot;","block_context":{"text":"Add-ons","link":"https:\/\/support.questetra.com\/en\/category\/addons\/"},"img":{"alt_text":"Google Drive: File Permissions, Add AnyoneWithLink","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Add-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Add-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Add-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Add-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/Google-Drive-File-Permissions-Add-AnyoneWithLink-en.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1","_links":{"self":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/183649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/comments?post=183649"}],"version-history":[{"count":6,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/183649\/revisions"}],"predecessor-version":[{"id":184061,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/183649\/revisions\/184061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/media\/168834"}],"wp:attachment":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/media?parent=183649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/categories?post=183649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/tags?post=183649"},{"taxonomy":"faq_section","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/faq_section?post=183649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}