zoom appsのWebhook認証をGo言語で通す

zoom appsでWebhookを使う時は72時間ごとに認証をする必要があります。 Go言語でzoomからのリクエストを処理する実装例です。 package main import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "encoding/json" "log" "net/http" "github.com/gin-gonic/gin" "github.com/ieee0824/getenv" ) type request struct { Payload struct { PlainToken string `json:"plainToken"` } `json:"payload"` EventTs int64 `json:"event_ts"` Event string `json:"event"` } type response struct { PlainToken string `json:"plainToken"` EncryptedToken string `json:"encryptedToken"` } func signHmac(secretKey string, message string) string { mac := hmac.New(sha256.New, []byte(secretKey)) mac.Write([]byte(message)) signature := mac.Sum(nil) ret := hex.EncodeToString(signature) return ret } func handler(ctx *gin.Context) { req := &request{} if err := json....

4月 26, 2023