AuthClient (auth/client.go)

go-micro · wrapper/auth/client.go · go · Apache-2.0
auth

Wraps a Go micro client to inject auth tokens into RPC calls.

// Source: https://github.com/micro/go-micro | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package auth

import (
	"context"

	"go-micro.dev/v6/auth"
	"go-micro.dev/v6/client"
	"go-micro.dev/v6/metadata"
)

// ClientOptions for configuring the auth client wrapper
type ClientOptions struct {
	// Auth provider for token generation
	Auth auth.Auth
	// Token to use (optional - if not provided, will be extracted from context)
	Token string
}

// AuthClient returns a client Wrapper that adds authentication tokens to outgoing requests.
//
// For each outgoing request:
// 1. Extracts or uses provided token
// 2. Adds Bearer token to request metadata
// 3. Makes the RPC call
//
// Exampl

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key