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
770
go-gmail-drafts
Yoshiki Nakagawa
January 22, 2016
Tweet
Share
More Decks by Yoshiki Nakagawa
See All by Yoshiki Nakagawa
MCP Documentation Server @AI Coding Meetup #1
yyoshiki41
2
3.2k
Go API クライアントの実装 〜Go Conference に載せれなかったTIPS〜
yyoshiki41
0
660
マルチテナントのアプリケーション実装 〜実践編〜
yyoshiki41
5
2.4k
Canary Deployments
yyoshiki41
0
500
Tests API
yyoshiki41
0
54
Graceful Upgrade for Go App
yyoshiki41
0
94
Other Decks in Technology
See All in Technology
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.6k
情熱と工夫で走り抜け! コミュニティをささえるObservability実践録
b1gb4by
1
120
Contract One Dev Group 紹介資料
sansan33
PRO
0
5.8k
AIの電力問題を概観する
rmaruy
0
160
AI駆動時代の新規事業の作り方
ryohysk
2
140
Introduction to Bill One Development Engineer
sansan33
PRO
0
230
Swiftは最高だよの話
yuukiw00w
0
210
令和トラベルQAのAI活用
seigaitakahiro
0
380
グループ ポリシー再確認 ③
murachiakira
0
140
declaration mergingの威力:ライブラリアップデート時の書き換え作業を90%短縮するテクニック
yutake27
2
240
ソフトウェアは捨てやすく作ろう/Let's make software easy to discard
sanogemaru
2
170
KMP導⼊において、マネジャーとして考えた事
sansantech
PRO
1
170
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
38
1.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Balancing Empowerment & Direction
lara
0
70
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
Speed Design
sergeychernyshev
30
960
Writing Fast Ruby
sferik
628
61k
Adopting Sorbet at Scale
ufuk
76
9.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Building Applications with DynamoDB
mza
95
6.4k
Making the Leap to Tech Lead
cromwellryan
133
9.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ʹొ͢ΕຖԼॻ͖࡞ʹ͑·͢ʂ