Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
go-gmail-drafts
Search
Yoshiki Nakagawa
January 22, 2016
Technology
0
760
go-gmail-drafts
Yoshiki Nakagawa
January 22, 2016
Tweet
Share
More Decks by Yoshiki Nakagawa
See All by Yoshiki Nakagawa
Go API クライアントの実装 〜Go Conference に載せれなかったTIPS〜
yyoshiki41
0
610
マルチテナントのアプリケーション実装 〜実践編〜
yyoshiki41
5
1.9k
Canary Deployments
yyoshiki41
0
470
Tests API
yyoshiki41
0
45
Graceful Upgrade for Go App
yyoshiki41
0
80
Other Decks in Technology
See All in Technology
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
kargoの魅力について伝える
magisystem0408
0
200
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
160
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
130
20241220_S3 tablesの使い方を検証してみた
handy
3
320
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
31k
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
220
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
180
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
210
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
Featured
See All Featured
Thoughts on Productivity
jonyablonski
67
4.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
A designer walks into a library…
pauljervisheath
204
24k
Designing Experiences People Love
moore
138
23k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Mobile First: as difficult as doing things right
swwweet
222
9k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Docker and Python
trallard
42
3.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Transcript
ΦʔϓϯιʔεϥΠϒϥϦݚڀձ #3 Jan / 22 / 2016 Yoshiki Nakagawa eureka,
Inc.
AboutMe @yyoshiki41 Yoshiki Nakagawa Infrastructure Engineer, pairs Division Tech •
Golang • Middleware, RDBMS • AWS
Google APIs Client Library for Go GitHub : https://github.com/google/google-api-go-client/ Enable
to access google APIs - Gmail API - BigQuery API - Calendar API etc...
yyoshiki41/go-gmail-drafts GitHub : https://github.com/yyoshiki41/go-gmail-drafts Create a new draft using the
Gmail API.
Why not Google Apps Script ? Apps Script is not
enough... Can't create drafts. (only get drafts) So use Google APIs Client Library ! Other languages libraries : https://developers.google.com/discovery/libraries All Libraries are open-sourced !
Preparation ̍. Google Developer Console ͔Βɺ৽نϓϩδΣΫτΛ࡞ ͢Δɻ ̎. ϓϩδΣΫτͷ Gmail
API Λ༗ޮʹ͢Δɻ
̏. ೝূใΛઃఆ͢Δɻ ̐. ඞཁͳೝূใΛΫϦοΫɻ
̑. OAuth ΫϥΠΞϯτͷઃఆɻ OAuthೝূΛྃͤ͞ɺJSONϑΝΠϧΛμϯϩʔυ͠·͢ɻ ޙͰ͍·͢ʂ
How to ̍. go get $ go get github.com/yyoshiki41/go-gmail-drafts $
cd $GOPATH/src/github.com/yyoshiki41/go-gmail-drafts ̎. μϯϩʔυͨ͠jsonϑΝΠϧΛઃஔɻ $ mv ~/Downloads/clientid.json config/clientsecret.json
̏. ॳճ࣮ߦ࣌OAuth௨͠ɺΞΫηετʔΫϯΛऔಘ͢Δɻ $ go run savetoken/main.go ϒϥβ͕ࣗಈͰ։͖ɺgoogleΞΧϯτͷೝূΛ͠·͢ɻ ࣍ʹɺGmailͰͷΞΫγϣϯΛڐՄ͠·͢ɻ
̑ɽςΩετϘοΫεʹදࣔ͞ΕͨcodeΛίϐʔ͢Δɻ λʔϛφϧʹͬͯɺtokenϑΝΠϧΛੜɻ ίϐʔͨ͠ίʔυΛషΓ͚Δɻ
̑. Լॻ͖ςϯϓϨΛ࡞ɻ { "to": "
[email protected]
", "subject": "Daily Reports", "message": "Hello!\nThis
is a draft." }
̒. go runͰ࣮ߦɻ $ go run main.go
ऴΘΓʹ go buildͰόΠφϦԽͯ͠ɺ cronʹొ͢ΕຖԼॻ͖࡞ʹ͑·͢ʂ