[Google App Script] ๋ฆฌํฌํŒ… ๋ฌธ์„œ , OpenByUrl ์—๋Ÿฌ
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋””์ง€ํ„ธ ๊ฟ€ํŒ

[Google App Script] ๋ฆฌํฌํŒ… ๋ฌธ์„œ , OpenByUrl ์—๋Ÿฌ

by ์ผ์ƒ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค 2022. 3. 1.

์˜ค๋Š˜ ํ•˜๋ฃจ์ข…์ผ ํ–ˆ๋Š”๋ฐ ์ฐฝํ”ผํ• ๋งŒํผ ์‹œ๊ฐ„์„ ๋งŽ์ด ์‚ฌ์šฉํ–ˆ์ง€๋งŒ ์›ํ•˜๋Š”๋Œ€๋กœ ํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.  ๊ตฌ๊ธ€ ์‚ฌ์ดํŠธ 100๊ฐœ ์ •๋„ ์‚ดํŽด๋ณด๊ณ  ์ฝ์–ด๋ณด๊ณ  ์กฐ๊ธˆ์”ฉ ์ˆœ์ฐจ์ ์œผ๋กœ ์ง„ํ–‰๋˜๋Š” ๊ฒƒ ๊ฐ™์•˜์ง€๋งŒ, ๊ฒฐ์ •์ ์ธ ์ˆœ๊ฐ„์—๋Š” ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์กฐ๊ธˆ์ด๋‚˜๋งˆ ๋‚˜๊ฐ™์ด ์‚ฝ์งˆํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์„ ์œ„ํ•ด ์ฐจ์„ ์ฑ…์„ ์ „๋‹ฌ๋“œ๋ ค๋ด…๋‹ˆ๋‹ค. 

์—๋Ÿฌ ์ข…๋ฅ˜


์—๋Ÿฌ ๋‚ด์šฉ์€ ๊ถŒํ•œ์ด ์—†๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. Exception: You do not have permission to call SpreadsheetApp. openByUrl. Required permissions: https://www.googleapis.com/auth/spreadsheets

 

https://www.googleapis.com/auth/spreadsheets

www.googleapis.com

 

์œ„์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ ํ•  ๊ฒฝ์šฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

  • apps script ์„ค์ •์—์„œ ์ผ๋ฐ˜์„ค์ • ์ฒดํฌ ํ•˜๊ธฐ 1→2 ์ˆœ์œผ๋กœ ํ™•์ธ

  • ์•„๋ž˜์™€ ๊ฐ™์ด appscript.json์— ์•„๋ž˜ ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
{
  "oauthScopes": [
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/drive",
    "https://www.googleapis.com/auth/drive.readonly",
    "https://www.googleapis.com/auth/drive.file",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/gmail.settings.basic",
    "https://www.googleapis.com/auth/gmail.readonly",
    "https://www.googleapis.com/auth/gmail.modify",
    "https://mail.google.com/",
    "https://www.googleapis.com/auth/script.external_request"
  ],


google cloud platform์„ ์‚ฌ์šฉํ–ˆ๋‹ค๊ณ  ํ•œ๋‹ค๋ฉด, ์ง์ ‘ API ์‚ฌ์šฉํ•˜๊ธฐ๋ฅผ ํด๋ฆญํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. 
๋งํฌ : https://console.cloud.google.com/apis/library?project=arboreal-retina-344902

์œ„ ๋ชฉ๋ก์ฃฝ์— ์‹ค์ œ๋กœ ์‚ฌ์šฉํ•˜๋Š” API๋ฅผ ํด๋ฆญํ•œ ํ›„์— ์•„๋ž˜ ์‚ฌ์šฉ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” ๋Œ€๋ถ€๋ถ„ ํ™œ์šฉ ํ•  ๊ฒƒ ๊ฐ™์•„ ๋ฌธ์„œ ๋ฐ gmail ๊ด€๋ จํ•œ API๋Š” ๋‹ค ์‚ฌ์šฉ์œผ๋กœ ํด๋ฆญํ•ด๋‘” ์ƒํ™ฉ์ž…๋‹ˆ๋‹ค. ์†Œ์Šค์— ๊ถŒํ•œ ์ถ”๊ฐ€๋ฅผ ๊ผญ ํ•จ๊ป˜ ํ•ด์ฃผ์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.  ๐Ÿ‘



3. Google App Script ์—์„œ ํŠน์ • ํ•จ์ˆ˜ ๊ตฌํ˜„ํ•œ ๊ฒƒ์„ ์Šคํ”„๋ ˆ๋“œ ์‹œํŠธ์—์„œ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ ํ•ด๋‹น app script ์•ˆ์—์„œ ํŠน์ • cell์— setvalue๋ฅผ ์‚ฌ์šฉ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.


๊ฑฐ์ง“๋ง์•ˆ์น˜๊ณ  ๋„ˆ๋ฌด ํž˜๋“ค๊ฒŒ ํ•˜๋ฃจ๋ฅผ ๊ณ ์ƒ ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋„ˆ๋ฌด ๊ณ ์ƒํ•˜์ง€๋ง๊ณ  ์œ„์™€ ๊ฐ™์ด ํ•ด๊ฒฐํ•˜์…จ์œผ๋ฉด ํ•˜๋Š” ๋ง˜์— ์ „๋‹ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ง„์งœ ๋‹ค๋ฅธ ํ•ด๊ฒฐ์ฑ…์ด ์žˆ๋‹ค๋ฉด ์•Œ๋ ค์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ™‡๐Ÿป‍โ™€๏ธ

๋Œ“๊ธ€