Coder Social home page Coder Social logo

go-gmail-drafts's Introduction

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": "[email protected]",
  "subject": "Daily Reports",
  "message": "Hello!\nThis is a draft."
}

Run!

$ go run main.go

sample

License


The MIT License

Author

Yoshiki Nakagawa

go-gmail-drafts's People

Contributors

yyoshiki41 avatar

Watchers

James Cloos avatar  avatar

go-gmail-drafts's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.