CorfedoCorfedoDocs

Authentication

Choose between browser sign-in and an API key, request the access your client needs and keep a session alive.

A client connects to one workspace. A person approves it in the browser, or the client holds an API key that a person created. Either way the client gets at most that person's access, limited to the repositories chosen for it.

Choose a credential

ClientCredential
Coding agent over MCPBrowser sign-in started by the agent. See Connect over MCP
CLI used by a personBrowser sign-in with corfedo auth login. See Sign in and profiles
CLI in CI and scriptsAPI key file
Application run by a personBrowser sign-in through an SDK, with session renewal
Service or headless agentAPI key file

Browser sign-in

The client opens the workspace's Authorize page, where the person chooses repositories and selects Allow. Under Permissions, every permission the client asks for is a checked box the person can clear. See Approve access. Signed-in clients appear under Connect › Manage connections, where the person can revoke them.

API keys

A person creates a key in Connect › Manage connections with Create API key and downloads the key file once. Keep it out of source code and pass its path to the SDK's key-file constructor, shown on each SDK page, or to corfedo auth configure-api-key.

A key keeps the permissions and repositories chosen when it was created. Ask Corfedo AI needs Search and read code. A key can select a repository where you hold at least one of its permissions.

A key can also have its own allowed networks, within the networks the workspace allows. From another network, requests fail with network_not_allowed (HTTP 403) and token requests with unauthorized_client or invalid_grant.

Permissions

The permissions are Search and read code, Dependencies, Security findings, Ask Corfedo AI, Read saved contexts, Manage your saved contexts and Manage workspace contexts. Permissions and scopes lists each with its OAuth scope. On each repository chosen for the client, it reads only what you can read there.

Request access to Corfedo AI

A workspace administrator turns Corfedo AI on per kind of client in Client access, and the client keeps Ask Corfedo AI and Search and read code:

ClientTurned on with
CLI, SDKs and API keysCorfedo AI under SDK and API
Coding agentsCorfedo AI under MCP clients, see MCP tools

While it is off, asking returns permission_denied (HTTP 403) and keys cannot be created with Ask Corfedo AI.

An SDK requests the corfedo:ai:invoke scope next to repository access. For TypeScript:

import { CorfedoAuthentication, CorfedoClient } from '@corfedo/client';

const credentials = await CorfedoAuthentication.signIn({
  apiBaseUri: 'https://corfedo.example.com/',
  scopes: [
    'corfedo:repositories:code:read',
    'corfedo:repositories:dependencies:read',
    'corfedo:ai:invoke',
    'offline_access',
  ],
});
const client = new CorfedoClient(credentials);

For Python, set HumanAuthenticationOptions.scopes to a tuple with the same values. For .NET, set HumanAuthenticationOptions.Scopes. offline_access lets the session be renewed.

SDK sign-in requests code and dependency read by default. Add corfedo:repositories:security:read for security findings. Asking also needs corfedo:repositories:code:read. A missing scope returns missing_scope (HTTP 403), AccessDenied with the missing scope in the SDKs.

Keep a human session alive

Access tokens are short-lived. Without renewal, a client built from human credentials fails with AuthenticationRequired when they expire. Then create a client with fresh credentials and reattach to the run.

For long-lived use, pass the SDK a renewal callback. Your application stores the credentials. Refresh tokens rotate and cannot be reused, so the callback must lock your session store, return a replacement another process already stored, or else refresh once and store the result:

from corfedo import CorfedoAuthentication, CorfedoClient, CorfedoCredentials

async def renew(current: CorfedoCredentials) -> CorfedoCredentials:
    async with store.lock():
        stored = await store.load()
        if stored.access_token != current.access_token:
            return stored
        replacement = await CorfedoAuthentication.refresh(current)
        await store.save(replacement)
        return replacement

client = CorfedoClient(credentials, renew=renew)

If the callback fails, that and every later call fail with ReauthorizationRequired. Sign in again and create a new client. To survive a process restart, store the proof key with the credentials, because the default one lives only in memory. With renewal, a stream that ends with credential_expired reattaches on its own.

On this page