googleapi

package
v0.0.497 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Google OAuth Setup (to send mails)

curl --request POST \
  --url https://oauth2.googleapis.com/token \
  --data code={...} \
  --data redirect_uri=http://localhost/oauth \
  --data client_id={...} \
  --data client_secret={...} \
  --data grant_type=authorization_code \
  --data scope=https://www.googleapis.com/auth/gmail.send
  • Fertig, mit client_id, client_secret und refresh_token kann das package benutzt werden

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleClient

type GoogleClient interface {
	SendMail(ctx context.Context, from string, recipients []string, cc []string, bcc []string, subject string, body MailBody, attachments []MailAttachment) (MailRef, error)
}

func NewGoogleClient

func NewGoogleClient(oauth GoogleOAuth) GoogleClient

type GoogleOAuth

type GoogleOAuth interface {
	AccessToken() (string, error)
}

func NewGoogleOAuth

func NewGoogleOAuth(clientid string, clientsecret, refreshtoken string) GoogleOAuth

type MailAttachment

type MailAttachment struct {
	IsInline    bool
	ContentType string
	Filename    string
	Data        []byte
}

type MailBody

type MailBody struct {
	Plain string
	HTML  string
}

type MailRef

type MailRef struct {
	ID       string   `json:"id"`
	ThreadID string   `json:"threadId"`
	LabelIDs []string `json:"labelIds"`
}

Jump to

Keyboard shortcuts

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