go-gmail-drafts

command module
v0.0.0-...-9fcc61f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2016 License: MIT Imports: 16 Imported by: 0

README

go-gmail-drafts

Create a new draft using the Gmail API.

Installation

$ go get -u github.com/yyoshiki41/go-gmail-drafts/...

Preparation

Configuration

1. Put your credential file
$ cd $GOPATH/src/github.com/yyoshiki41/go-gmail-drafts
$ mv /path/to/client_secret.json config/client_secret.json
2. Save access token to cachefile

Open the browser automatically when exec go run command.

After authorize Google APIs, paste authorization code into the command-line prompt.

$ go run savetoken/main.go
URL: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=hogehoge.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.compose+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.modify&state=state-token
Type the authorization code.
### Paste authorization code here! ###
Saving credential file to: .credentials/gmail_token.json

$ cat .credentials/gmail_token.json | jq .
{
  "access_token": "xxxxx",
  "token_type": "Bearer",
  "refresh_token": "xxxxx",
  "expiry": "2016-01-22T11:11:47.804107777+09:00"
}
Example

Create a gmail template.

$ cp config/draft_tmpl.json.skel config/draft_tmpl.json
$ vim config/draft_tmpl.json
{
  "to": "xxx@gmail.com",
  "subject": "Daily Reports",
  "message": "Hello!\nThis is a draft."
}

Run!

$ go run main.go

sample

License


The MIT License

Author

Yoshiki Nakagawa

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL