openrouterauth

package
v0.2.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package openrouterauth connects a local codeaf profile to OpenRouter without asking the person to make and copy an API key by hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flow

type Flow struct {
	// contains filtered or unexported fields
}

Flow is one browser connection in progress. The loopback listener is already standing when Begin returns, so URL may be opened immediately and Wait may safely run on another goroutine.

func Begin

func Begin(ctx context.Context, options Options) (*Flow, error)

Begin starts an S256 PKCE connection on an arbitrary loopback port.

OpenRouter explicitly accepts localhost callbacks on any port, so there is no fixed socket to contend for and no public redirect service in the middle. The callback path is random as well: the verifier protects the exchanged code, and the unguessable path keeps an unrelated local request from ending the person's attempt early.

func (*Flow) Cancel

func (f *Flow) Cancel()

Cancel releases the loopback listener and makes a waiting call return.

func (*Flow) URL

func (f *Flow) URL() string

URL is the OpenRouter sign-in address to open in the person's browser.

func (*Flow) Wait

func (f *Flow) Wait(ctx context.Context) (string, error)

Wait blocks until the browser trip has exchanged its one-time code for a user-controlled API key, the caller leaves, or the flow is cancelled.

type Options

type Options struct {
	AuthURL     string
	ExchangeURL string
	HTTPClient  *http.Client
	Random      io.Reader
	Listen      func(network, address string) (net.Listener, error)
}

Options holds the replaceable edges of an OpenRouter connection. Its zero value is the shipped service; tests replace the endpoints, entropy and listener without sending a browser or a credential outside the process.

Jump to

Keyboard shortcuts

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