MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / ListAPIKeys

Method ListAPIKeys

internal/identity/store.go:3462–3481  ·  view source on GitHub ↗
(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

3460}
3461
3462func (s *Store) ListAPIKeys(ctx context.Context, userID string) ([]APIKey, error) {
3463 rows, err := s.pool.Query(ctx,
3464 `SELECT id, user_id, name, key_prefix, COALESCE(scope, 'account'), agent_id, created_at, last_used_at, expires_at
3465 FROM api_keys WHERE user_id = $1 AND revoked_at IS NULL ORDER BY created_at DESC`,
3466 userID,
3467 )
3468 if err != nil {
3469 return nil, err
3470 }
3471 defer rows.Close()
3472 var keys []APIKey
3473 for rows.Next() {
3474 var k APIKey
3475 if err := rows.Scan(&k.ID, &k.UserID, &k.Name, &k.KeyPrefix, &k.Scope, &k.AgentID, &k.CreatedAt, &k.LastUsedAt, &k.ExpiresAt); err != nil {
3476 return nil, err
3477 }
3478 keys = append(keys, k)
3479 }
3480 return keys, rows.Err()
3481}
3482
3483// ErrAPIKeyNotFound is returned by DeleteAPIKey when no live key matched the
3484// (id, user) — i.e. it doesn't exist, isn't owned by the caller, or was

Callers 7

TestListAPIKeysFunction · 0.95
TestDeleteAPIKeyFunction · 0.95
handleListAPIKeysMethod · 0.80
HandleListAPIKeysMethod · 0.80
seedProbeFunction · 0.80

Implementers 1

Storeinternal/identity/store.go

Calls 5

QueryMethod · 0.80
NextMethod · 0.80
ScanMethod · 0.80
ErrMethod · 0.80
CloseMethod · 0.45