SASL/OAUTHBEARER Access Token Provider
Overview
This pkg is intended to be used as a complement to Shopify/sarama. It provides an implementation of the sarama.AccessTokenProvider
interface to be employed by clients using the SASL/OAUTHBEARER mechanism for Apache Kafka.
This package leverages golang/oauth2
and golang/oauth2/clientcredentials
to perform the 2 legged client credentials flow to obtain an Access Token outside the context of a user.
Installation
go get github.com/damiannolan/sasl/oauthbearer
Usage
The appropriate configuration settings must be set on the sarama.Config
. It is recommended to use this protocol over TLS.
import (
"github.com/damiannolan/sasl/oauthbearer"
)
func main() {
cfg := sarama.NewConfig()
cfg.Net.SASL.Enable = true
cfg.Net.SASL.Mechanism = sarama.SASLTypeOAuth
cfg.Net.SASL.AccessTokenProvider = oauthbearer.NewTokenProvider(clientID, clientSecret, tokenURL)
...
}
References