# Authentication Guide for AI Agents: Alshhbaa Brassware (نحاسيات الشهباء)

Alshhbaa Brassware provides public discovery and agent-authenticated workflows for luxury chandelier design, bespoke manufacturing inquiries, quotation submissions, and showroom consultation.

## 1. Discover

Agents discover authentication and authorization configuration using standard RFC 9728 and RFC 8414 metadata:

- Protected Resource Metadata (RFC 9728): `https://alshhbaa.com/.well-known/oauth-protected-resource`
- Authorization Server Metadata (RFC 8414): `https://alshhbaa.com/.well-known/oauth-authorization-server`
- Agent Auth Skill Guide: `https://alshhbaa.com/auth.md`
- Challenge Header: When an endpoint requires authentication, it issues an HTTP `401 Unauthorized` with:
  `WWW-Authenticate: Bearer resource_metadata="https://alshhbaa.com/.well-known/oauth-protected-resource"`

The authorization server metadata contains an `agent_auth` block that advertises available identity and registration endpoints.

## 2. Pick a method

Supported identity types from `agent_auth.identity_types_supported`:

- `anonymous`: Instant read-only access to public discovery endpoints, project portfolios, and showroom information without minting credentials.
- `identity_assertion`: Agent providers assert identity using an ID-JAG token (`urn:ietf:params:oauth:token-type:id-jag`) for autonomous verified interactions.
- `service_auth`: Direct API client credentials for integrated enterprise systems and persistent partner agents.

## 3. Register

For authenticated agent sessions, register or submit identity assertion to the `identity_endpoint`:

- Endpoint: `https://alshhbaa.com/agent/identity`
- Method: `POST`
- Content-Type: `application/json`

Payload for `identity_assertion` using `id-jag`:

```json
{
  "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
  "subject_token_type": "urn:ietf:params:oauth:token-type:id-jag",
  "subject_token": "<ID-JAG-JWT>",
  "scope": "public read:projects submit:consultation"
}
```

## 4. Claim

If a user-in-the-loop claim is required, navigate to the `claim_endpoint`:

- Endpoint: `https://alshhbaa.com/agent/identity/claim`
- Method: `GET` or `POST`
- The user confirms authorization or provides a one-time code to link the agent session to their customer account.

## 5. Exchange

Once claimed or identity assertion is validated, the agent exchanges the authorization code or verification grant at the token endpoint:

- Token Endpoint: `https://alshhbaa.com/agent/token`
- Request: `POST` with `grant_type` and credentials.
- Response: Returns a JSON payload containing `access_token`, `token_type: "Bearer"`, and `expires_in: 3600`.

## 6. Use the access_token

Include the access token in HTTP requests as a Bearer token:

```http
GET /api/v1/projects HTTP/1.1
Host: alshhbaa.com
Authorization: Bearer <access_token>
```

Write requests (`POST`, `PUT`, `PATCH`) should also supply an `Idempotency-Key` header:

```http
POST /api/v1/consultations HTTP/1.1
Host: alshhbaa.com
Authorization: Bearer <access_token>
Idempotency-Key: <unique-uuid>
X-API-Version: v1
Content-Type: application/json
```

## 7. Errors

Unauthenticated or expired requests receive `401 Unauthorized` with the challenge header:
`WWW-Authenticate: Bearer error="invalid_token", resource_metadata="https://alshhbaa.com/.well-known/oauth-protected-resource"`

All API error responses return typed schemas conforming to RFC 9457 `application/problem+json` and standard `application/json` with a machine-readable `code` and human-readable `message`.

## 8. Revocation

To revoke an active agent token or terminate authorization:

- Endpoint: `https://alshhbaa.com/agent/token/revoke`
- Method: `POST`
- Content-Type: `application/json`
- Payload: `{"token": "<access_token>"}`