func (info *jwtInfo) Token(ctx context.Context, signer cryptoSigner) (string, error) {
	encode := func(i interface{}) (string, error) {
		b, err := json.Marshal(i)
		if err != nil {
			return "", err
		}
		return base64.RawURLEncoding.EncodeToString(b), nil
	}
	header, err := encode(info.header)
	if err != nil {
		return "", err
	}
	payload, err := encode(info.payload)
	if err != nil {
		return "", err
	}
	tokenData := fmt.Sprintf("%s.%s", header, payload)
	sig, err := signer.Sign(ctx, []byte(tokenData))
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%s.%s", tokenData, base64.RawURLEncoding.EncodeToString(sig)), nil
}
Token encodes the data in the jwtInfo into a signed JSON web token.
package auth
import (
	"context"
	"crypto"
	"crypto/rand"
	"crypto/rsa"
	"crypto/sha256"
	"crypto/x509"
	"encoding/base64"
	"encoding/json"
	"encoding/pem"
	"errors"
	"fmt"
	"net/http"
	"strings"
	"sync"
	"firebase.google.com/go/v4/internal"
)
const (
	algorithmNone  = "none"
	algorithmRS256 = "RS256"
	emulatorEmail = "firebase-auth-emulator@example.com"
)
type jwtHeader struct {
	Algorithm string `json:"alg"`
	Type      string `json:"typ"`
	KeyID     string `json:"kid,omitempty"`
}
type customToken struct {
	Iss      string                 `json:"iss"`
	Aud      string                 `json:"aud"`
	Exp      int64                  `json:"exp"`
	Iat      int64                  `json:"iat"`
	Sub      string                 `json:"sub,omitempty"`
	UID      string                 `json:"uid,omitempty"`
	TenantID string                 `json:"tenant_id,omitempty"`
	Claims   map[string]interface{} `json:"claims,omitempty"`
}
type jwtInfo struct {
	header  jwtHeader
	payload interface{}
}