credentials

package
v0.1.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package credentials lets an agent obtain a user's access to a third-party API in the middle of a task, the case A2A models as TASK_STATE_AUTH_REQUIRED (spec 7.6), without the agent ever holding the user's raw token.

The flow is:

  1. Lookup: does the user already have a connection for the integration?
  2. If not, Begin returns a Challenge with a link. The agent puts the task into AUTH_REQUIRED and sends the link with NewChallengeParts.
  3. Await blocks until the user completes the flow at the broker. Spec 7.6.1 lets the agent continue on its own at that point, without a follow-up message.
  4. The agent calls the provider's API through Grant.Call. The broker adds the credential, so the token never travels through the chain of A2A agents (spec 7.6.3).

Implementations: credentials/demo (a fake consent page, no accounts needed) and credentials/nango (Nango Connect, then API calls through the Nango proxy).

Index

Constants

View Source
const MetadataKey = "https://threeagents.dev/ext/credential-challenge/v1"

MetadataKey marks the data part that carries a Challenge in an AUTH_REQUIRED status message. It lets a client or console show a "connect" button instead of parsing text.

Variables

View Source
var (
	// ErrNoGrant means the user has no usable connection for the integration.
	ErrNoGrant = errors.New("credentials: no grant for this user and integration")
	// ErrDenied means the user declined the request.
	ErrDenied = errors.New("credentials: the user denied access")
	// ErrExpired means the challenge expired before the user completed it.
	ErrExpired = errors.New("credentials: the challenge expired")
)

Functions

func NewChallengeParts

func NewChallengeParts(c *Challenge, reason string) []*a2a.Part

NewChallengeParts returns the parts of an AUTH_REQUIRED status message: a sentence for humans and a data part with the challenge for machines.

Types

type Broker

type Broker interface {
	// Lookup returns the user's existing grant for the integration, or ErrNoGrant.
	Lookup(ctx context.Context, user, integration string) (Grant, error)
	// Begin starts a new authorization flow and returns the link to send to the user.
	Begin(ctx context.Context, user, integration string) (*Challenge, error)
	// Await blocks until the challenge is completed, denied, expired or ctx is done.
	Await(ctx context.Context, challenge *Challenge) (Grant, error)
}

Broker obtains and uses user credentials on an agent's behalf.

type Challenge

type Challenge struct {
	// ID is the broker's identifier for this flow.
	ID          string    `json:"id"`
	User        string    `json:"user"`
	Integration string    `json:"integration"`
	URL         string    `json:"url"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

Challenge is an authorization flow waiting for the user.

func ChallengeFromMessage

func ChallengeFromMessage(msg *a2a.Message) (*Challenge, bool)

ChallengeFromMessage finds a Challenge written by NewChallengeParts.

type Grant

type Grant interface {
	// ConnectionID identifies the connection at the broker.
	ConnectionID() string
	// Call sends a request to a path of the provider's API, for example
	// "/calendar/v3/calendars/primary/events", with body encoded as JSON. When out is
	// non-nil, the JSON response is decoded into it.
	Call(ctx context.Context, method, path string, body, out any) error
}

Grant is a connection the user approved.

Directories

Path Synopsis
Package demo is a credentials.Broker that needs no accounts: its consent page is a local web page, and the only provider API it fakes is Google Calendar event creation.
Package demo is a credentials.Broker that needs no accounts: its consent page is a local web page, and the only provider API it fakes is Google Calendar event creation.
Package nango is a credentials.Broker backed by Nango (https://nango.dev).
Package nango is a credentials.Broker backed by Nango (https://nango.dev).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL