You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: oauth.go
    path of file: ./repos/franz-go/pkg/sasl/oauth
    
    the code of the file until where you have to start completion: // Package oauth provides OAUTHBEARER sasl authentication as specified in
// RFC7628.
package oauth

import (
	"context"
	"errors"
	"sort"

	"github.com/twmb/franz-go/pkg/sasl"
)

// Auth contains information for authentication.
//
// This client may add fields to this struct in the future if Kafka adds more
// capabilities to Oauth.
type Auth struct {
	/
    
func (fn oauth) Authenticate(ctx context.Context, _ string) (sasl.Session, []byte, error) {
	auth, err := fn(ctx)
	if err != nil {
		return nil, nil, err
	}
	if auth.Token == "" {
		return nil, nil, errors.New("OAUTHBEARER token must be non-empty")
	}

	// We sort extensions for consistency, but it is not required.
	type kv struct {
		k string
		v string
	}
	kvs := make([]kv, 0, len(auth.Extensions))
	for k, v := range auth.Extensions {
		if len(k) == 0 {
			continue
		}
		kvs = append(kvs, kv{k, v})
	}
	sort.Slice(kvs, func(i, j int) bool { return kvs[i].k < kvs[j].k })

	// https://tools.ietf.org/html/rfc7628#section-3.1
	gs2Header := "n," // no channel binding
	if auth.Zid != "" {
		gs2Header += "a=" + auth.Zid
	}
	gs2Header += ","
	init := []byte(gs2Header + "\x01auth=Bearer ")
	init = append(init, auth.Token...)
	init = append(init, '\x01')
	for _, kv := range kvs {
		init = append(init, kv.k...)
		init = append(init, '=')
		init = append(init, kv.v...)
		init = append(init, '\x01')
	}
	init = append(init, '\x01')

	return session{}, init, nil
}