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
600
マルチテナントのアプリケーション実装 〜実践編〜
yyoshiki41
5
1.8k
Canary Deployments
yyoshiki41
0
470
Tests API
yyoshiki41
0
45
Graceful Upgrade for Go App
yyoshiki41
0
79
Other Decks in Technology
See All in Technology
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
Lexical Analysis
shigashiyama
1
150
Lambdaと地方とコミュニティ
miu_crescent
2
370
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
170
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
750
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
複雑なState管理からの脱却
sansantech
PRO
1
140
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
Can We Measure Developer Productivity?
ewolff
1
150
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Gamification - CAS2011
davidbonilla
80
5k
Done Done
chrislema
181
16k
A Philosophy of Restraint
colly
203
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Code Review Best Practice
trishagee
64
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Practical Orchestrator
shlominoach
186
10k
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ʹొ͢ΕຖԼॻ͖࡞ʹ͑·͢ʂ