Gmail API for Go에서 초안 생성 도구를 만들었습니다.
개요
Google APIs Client Library for Go를 사용하여,
Gmail API 초안을 만드는 도구를 만들었습니다.
go-gmail-drafts
아래 준비
1. Google Developer Console에서 새 프로젝트를 만듭니다.

2. 프로젝트의 Gmail API을 활성화합니다.

3. 인증 정보를 설정한다.

필요한 자격 증명을 클릭합니다.

OAuth 클라이언트를 설정하고 JSON 파일을 다운로드합니다.
나중에 사용!

사용법
1.
go get
$ go get github.com/yyoshiki41/go-gmail-drafts
$ cd $GOPATH/src/github.com/yyoshiki41/go-gmail-drafts
2. 방금 다운로드한 json 파일을
config/client_secret.json
로 배치.$ mv ~/Downloads/client_id.json config/client_secret.json
3. 최초 실행시에는 OAuth를 통해 액세스 토큰을 취득한다.
$ go run savetoken/main.go
브라우저가 자동으로 열리므로 google 계정 인증을 통과합니다.
그런 다음 Gmail에서 액션을 허용합니다.

텍스트 상자에 표시된 코드를 복사합니다.

4. 터미널로 돌아가 토큰 파일을 생성.
위에서 복사한 코드를 붙여넣습니다.
$ 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.
### コードをペーストする ###
Saving credential file to: .credentials/gmail_token.json
.credentials/gmail_token.json
파일이 생성됩니다.5. 초안 템플리를 작성.
{
"to": "[email protected]",
"subject": "Daily Reports",
"message": "Hello!\nThis is a draft."
}
6.
go run
에서 실행.$ go run main.go

끝에
go build
로 바이너리화하여 cron 등에 등록하면 매일 초안 작성 등에 사용할 수 있습니다!
Reference
이 문제에 관하여(Gmail API for Go에서 초안 생성 도구를 만들었습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/yyoshiki41/items/1159e1a70ffaa8fd84ed텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)