@portpowered/reference-data 0.4.10 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/generated/capabilities.json +288 -7
  2. package/generated/guides.json +4 -4
  3. package/generated/openapi.json +284 -10
  4. package/generated/public/docs/for-ai/api-catalog.md +2 -1
  5. package/generated/public/docs/for-ai/capability-interfaces/media-player/1.0.md +1 -0
  6. package/generated/public/docs/for-ai/capability-interfaces/reminders-provider/1.0.md +8 -2
  7. package/generated/public/docs/for-ai/guides/authentication-and-dcr.md +26 -4
  8. package/generated/public/docs/for-ai/guides/oauth-consent-and-callback.md +23 -1
  9. package/generated/public/docs/for-ai/guides/oauth-discovery.md +2 -2
  10. package/generated/public/docs/for-ai/guides/oauth-token-lifecycle.md +1 -1
  11. package/generated/public/docs/for-ai/operations/beginOAuthAuthorization.md +2 -2
  12. package/generated/public/docs/for-ai/operations/completeOAuthConsent.md +5 -2
  13. package/generated/public/docs/for-ai/operations/deliverOAuthAuthorizationResponse.md +74 -0
  14. package/generated/public/docs/for-ai/operations/index.md +1 -0
  15. package/generated/public/docs/for-ai/schemas/m-1.md +1 -1
  16. package/generated/public/docs/for-ai/schemas/m-2.md +1 -0
  17. package/generated/public/docs/for-ai/schemas/r-1.md +7 -7
  18. package/generated/public/docs/for-ai/schemas/r-2.md +7 -0
  19. package/generated/public/docs/for-ai/schemas.md +4 -4
  20. package/generated/public/docs/references/authorization.json +9 -0
  21. package/generated/public/docs/references/authorization.yaml +7 -0
  22. package/generated/public/docs/references/capability-interfaces/media-player/1.0/attributes/now-playing.yaml +7 -0
  23. package/generated/public/docs/references/capability-interfaces/media-player/1.0/messages/transfer-playback.yaml +10 -0
  24. package/generated/public/docs/references/capability-interfaces/media-player/1.0.yaml +26 -0
  25. package/generated/public/docs/references/capability-interfaces/media-player.yaml +26 -0
  26. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/create-reminder-response.yaml +33 -0
  27. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/create-reminder.yaml +20 -0
  28. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/delete-reminder-response.yaml +4 -0
  29. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/delete-reminder.yaml +16 -0
  30. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/list-reminders-response.yaml +34 -2
  31. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/list-reminders.yaml +17 -1
  32. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/update-reminder-response.yaml +33 -0
  33. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0/messages/update-reminder.yaml +26 -0
  34. package/generated/public/docs/references/capability-interfaces/reminders-provider/1.0.yaml +202 -4
  35. package/generated/public/docs/references/capability-interfaces/reminders-provider.yaml +202 -4
  36. package/generated/public/docs/references/manifest.json +206 -74
  37. package/generated/public/docs/references/openapi.yaml +236 -7
  38. package/generated/public/docs/references/schemas/MediaPlayerInterfaceNowPlayingAttribute.json +5 -0
  39. package/generated/public/docs/references/schemas/MediaPlayerInterfaceTransferPlaybackMessage.json +11 -0
  40. package/generated/public/docs/references/schemas/Reminder.json +33 -0
  41. package/generated/public/docs/references/schemas/RemindersProviderInterfaceCreateReminderMessage.json +31 -0
  42. package/generated/public/docs/references/schemas/RemindersProviderInterfaceCreateReminderResponseMessage.json +20 -0
  43. package/generated/public/docs/references/schemas/RemindersProviderInterfaceDeleteReminderMessage.json +28 -0
  44. package/generated/public/docs/references/schemas/RemindersProviderInterfaceDeleteReminderResponseMessage.json +12 -0
  45. package/generated/public/docs/references/schemas/RemindersProviderInterfaceListRemindersMessage.json +23 -2
  46. package/generated/public/docs/references/schemas/RemindersProviderInterfaceListRemindersResponseMessage.json +15 -4
  47. package/generated/public/docs/references/schemas/RemindersProviderInterfaceUpdateReminderMessage.json +39 -0
  48. package/generated/public/docs/references/schemas/RemindersProviderInterfaceUpdateReminderResponseMessage.json +20 -0
  49. package/generated/public/docs/references/schemas/index.json +48 -0
  50. package/generated/resources/media-player/message-transfer-playback.json +5 -0
  51. package/generated/resources/media-player/state-now-playing.json +5 -0
  52. package/generated/resources/reminders-provider/message-create-reminder-response.json +44 -0
  53. package/generated/resources/reminders-provider/message-create-reminder.json +25 -0
  54. package/generated/resources/reminders-provider/message-delete-reminder-response.json +6 -0
  55. package/generated/resources/reminders-provider/message-delete-reminder.json +22 -0
  56. package/generated/resources/reminders-provider/message-list-reminders-response.json +44 -3
  57. package/generated/resources/reminders-provider/message-list-reminders.json +23 -2
  58. package/generated/resources/reminders-provider/message-update-reminder-response.json +44 -0
  59. package/generated/resources/reminders-provider/message-update-reminder.json +33 -0
  60. package/package.json +1 -1
@@ -4611,6 +4611,16 @@
4611
4611
  "type": "object",
4612
4612
  "additionalProperties": false
4613
4613
  }
4614
+ },
4615
+ {
4616
+ "name": "transfer-playback",
4617
+ "description": "Move the current playback session of the destination route's connected provider account to this one destination, preserving playing or paused state and media context. Select an advertised destination route. This affects that account's current session; it does not copy media, restart playback, transfer between providers or accounts, or fan out to group members. Read fresh source and destination state before and after dispatch to verify the move. An unavailable target requires an explicit choice of another destination.",
4618
+ "directionality": "in",
4619
+ "schema": {
4620
+ "description": "Move the current playback session of the destination route's connected provider account to this one destination, preserving playing or paused state and media context. Select an advertised destination route. This affects that account's current session; it does not copy media, restart playback, transfer between providers or accounts, or fan out to group members. Read fresh source and destination state before and after dispatch to verify the move. An unavailable target requires an explicit choice of another destination.",
4621
+ "type": "object",
4622
+ "additionalProperties": false
4623
+ }
4614
4624
  }
4615
4625
  ],
4616
4626
  "attributes": [
@@ -4637,6 +4647,11 @@
4637
4647
  },
4638
4648
  "name": {
4639
4649
  "type": "string"
4650
+ },
4651
+ "positionMs": {
4652
+ "description": "Provider-observed position within the current media item in milliseconds. Omitted when unknown. Compare fresh observations with media identity and playback state; a track transition does not prove continuity.",
4653
+ "type": "integer",
4654
+ "minimum": 0
4640
4655
  }
4641
4656
  },
4642
4657
  "required": [
@@ -7208,23 +7223,162 @@
7208
7223
  "version": "1.0",
7209
7224
  "description": "Reminder providers list reminders from a connected account. Use the returned items to give an assistant task context or display an existing reminder list.",
7210
7225
  "messages": [
7226
+ {
7227
+ "name": "create-reminder",
7228
+ "description": "Create a reminder in a discovered list. Creation is sent once; refresh before retrying an uncertain result.",
7229
+ "directionality": "in",
7230
+ "schema": {
7231
+ "description": "Create a reminder in a discovered list. Creation is sent once; refresh before retrying an uncertain result.",
7232
+ "type": "object",
7233
+ "additionalProperties": false,
7234
+ "properties": {
7235
+ "listId": {
7236
+ "type": "string",
7237
+ "minLength": 1,
7238
+ "description": "Discovered list identifier."
7239
+ },
7240
+ "title": {
7241
+ "type": "string",
7242
+ "minLength": 1,
7243
+ "description": "Reminder title."
7244
+ },
7245
+ "notes": {
7246
+ "type": "string"
7247
+ }
7248
+ },
7249
+ "required": [
7250
+ "listId",
7251
+ "title"
7252
+ ],
7253
+ "title": "RemindersProviderInterfaceCreateReminderMessage"
7254
+ }
7255
+ },
7256
+ {
7257
+ "name": "create-reminder-response",
7258
+ "description": "The provider accepted the reminder change.",
7259
+ "directionality": "out",
7260
+ "schema": {
7261
+ "description": "The provider accepted the reminder change.",
7262
+ "type": "object",
7263
+ "additionalProperties": false,
7264
+ "properties": {
7265
+ "reminder": {
7266
+ "type": "object",
7267
+ "additionalProperties": false,
7268
+ "description": "A reminder and its current provider revision for guarded edits.",
7269
+ "properties": {
7270
+ "reminderId": {
7271
+ "type": "string"
7272
+ },
7273
+ "listId": {
7274
+ "type": "string"
7275
+ },
7276
+ "title": {
7277
+ "type": "string"
7278
+ },
7279
+ "notes": {
7280
+ "type": "string"
7281
+ },
7282
+ "completed": {
7283
+ "type": "boolean"
7284
+ },
7285
+ "revision": {
7286
+ "type": "string",
7287
+ "description": "Omitted when the provider does not supply a revision; writes require it."
7288
+ }
7289
+ },
7290
+ "required": [
7291
+ "reminderId",
7292
+ "listId",
7293
+ "title",
7294
+ "completed"
7295
+ ],
7296
+ "title": "Reminder"
7297
+ }
7298
+ },
7299
+ "required": [
7300
+ "reminder"
7301
+ ],
7302
+ "title": "RemindersProviderInterfaceCreateReminderResponseMessage"
7303
+ }
7304
+ },
7305
+ {
7306
+ "name": "delete-reminder",
7307
+ "description": "Soft-delete a reminder using its last observed revision.",
7308
+ "directionality": "in",
7309
+ "schema": {
7310
+ "description": "Soft-delete a reminder using its last observed revision.",
7311
+ "type": "object",
7312
+ "additionalProperties": false,
7313
+ "properties": {
7314
+ "reminderId": {
7315
+ "type": "string",
7316
+ "minLength": 1,
7317
+ "description": "Reminder identifier."
7318
+ },
7319
+ "revision": {
7320
+ "type": "string",
7321
+ "minLength": 1,
7322
+ "description": "Revision from the latest listing."
7323
+ }
7324
+ },
7325
+ "required": [
7326
+ "reminderId",
7327
+ "revision"
7328
+ ],
7329
+ "title": "RemindersProviderInterfaceDeleteReminderMessage"
7330
+ }
7331
+ },
7332
+ {
7333
+ "name": "delete-reminder-response",
7334
+ "description": "The provider accepted soft deletion of the reminder.",
7335
+ "directionality": "out",
7336
+ "schema": {
7337
+ "description": "The provider accepted soft deletion of the reminder.",
7338
+ "type": "object",
7339
+ "additionalProperties": false,
7340
+ "title": "RemindersProviderInterfaceDeleteReminderResponseMessage"
7341
+ }
7342
+ },
7211
7343
  {
7212
7344
  "name": "list-reminders",
7213
- "description": "Request to list reminders from a reminders provider",
7345
+ "description": "List reminder lists and their reminders. Omit listId to enumerate all lists.",
7214
7346
  "directionality": "in",
7215
7347
  "schema": {
7216
- "description": "Request to list reminders from a reminders provider",
7348
+ "description": "List reminder lists and their reminders. Omit listId to enumerate all lists.",
7217
7349
  "type": "object",
7218
- "additionalProperties": false
7350
+ "additionalProperties": false,
7351
+ "properties": {
7352
+ "listId": {
7353
+ "type": "string",
7354
+ "minLength": 1,
7355
+ "description": "List identifier from a previous listing."
7356
+ },
7357
+ "includeCompleted": {
7358
+ "type": "boolean",
7359
+ "default": false
7360
+ },
7361
+ "cursor": {
7362
+ "type": "string",
7363
+ "description": "Opaque next-page cursor."
7364
+ },
7365
+ "maxResults": {
7366
+ "type": "integer",
7367
+ "minimum": 1,
7368
+ "maximum": 1000
7369
+ }
7370
+ },
7371
+ "title": "RemindersProviderInterfaceListRemindersMessage"
7219
7372
  }
7220
7373
  },
7221
7374
  {
7222
7375
  "name": "list-reminders-response",
7223
- "description": "Response containing a list of reminder lists from a reminders provider",
7376
+ "description": "Reminder lists and one bounded page of reminders.",
7224
7377
  "directionality": "out",
7225
7378
  "schema": {
7226
- "description": "Response containing a list of reminder lists from a reminders provider",
7379
+ "description": "Reminder lists and one bounded page of reminders.",
7227
7380
  "type": "object",
7381
+ "additionalProperties": false,
7228
7382
  "properties": {
7229
7383
  "reminderLists": {
7230
7384
  "type": "array",
@@ -7244,12 +7398,139 @@
7244
7398
  ],
7245
7399
  "title": "ReminderList"
7246
7400
  }
7401
+ },
7402
+ "reminders": {
7403
+ "type": "array",
7404
+ "items": {
7405
+ "type": "object",
7406
+ "additionalProperties": false,
7407
+ "description": "A reminder and its current provider revision for guarded edits.",
7408
+ "properties": {
7409
+ "reminderId": {
7410
+ "type": "string"
7411
+ },
7412
+ "listId": {
7413
+ "type": "string"
7414
+ },
7415
+ "title": {
7416
+ "type": "string"
7417
+ },
7418
+ "notes": {
7419
+ "type": "string"
7420
+ },
7421
+ "completed": {
7422
+ "type": "boolean"
7423
+ },
7424
+ "revision": {
7425
+ "type": "string",
7426
+ "description": "Omitted when the provider does not supply a revision; writes require it."
7427
+ }
7428
+ },
7429
+ "required": [
7430
+ "reminderId",
7431
+ "listId",
7432
+ "title",
7433
+ "completed"
7434
+ ],
7435
+ "title": "Reminder"
7436
+ }
7437
+ },
7438
+ "nextCursor": {
7439
+ "type": "string"
7247
7440
  }
7248
7441
  },
7249
7442
  "required": [
7250
- "reminderLists"
7443
+ "reminderLists",
7444
+ "reminders"
7251
7445
  ],
7252
- "additionalProperties": false
7446
+ "title": "RemindersProviderInterfaceListRemindersResponseMessage"
7447
+ }
7448
+ },
7449
+ {
7450
+ "name": "update-reminder",
7451
+ "description": "Edit a reminder using its last observed revision; omitted fields are preserved.",
7452
+ "directionality": "in",
7453
+ "schema": {
7454
+ "description": "Edit a reminder using its last observed revision; omitted fields are preserved.",
7455
+ "type": "object",
7456
+ "additionalProperties": false,
7457
+ "properties": {
7458
+ "reminderId": {
7459
+ "type": "string",
7460
+ "minLength": 1,
7461
+ "description": "Reminder identifier."
7462
+ },
7463
+ "revision": {
7464
+ "type": "string",
7465
+ "minLength": 1,
7466
+ "description": "Revision from the latest listing."
7467
+ },
7468
+ "title": {
7469
+ "type": "string",
7470
+ "minLength": 1,
7471
+ "description": "Replacement title."
7472
+ },
7473
+ "notes": {
7474
+ "type": "string"
7475
+ },
7476
+ "completed": {
7477
+ "type": "boolean"
7478
+ }
7479
+ },
7480
+ "required": [
7481
+ "reminderId",
7482
+ "revision"
7483
+ ],
7484
+ "title": "RemindersProviderInterfaceUpdateReminderMessage"
7485
+ }
7486
+ },
7487
+ {
7488
+ "name": "update-reminder-response",
7489
+ "description": "The provider accepted the reminder change.",
7490
+ "directionality": "out",
7491
+ "schema": {
7492
+ "description": "The provider accepted the reminder change.",
7493
+ "type": "object",
7494
+ "additionalProperties": false,
7495
+ "properties": {
7496
+ "reminder": {
7497
+ "type": "object",
7498
+ "additionalProperties": false,
7499
+ "description": "A reminder and its current provider revision for guarded edits.",
7500
+ "properties": {
7501
+ "reminderId": {
7502
+ "type": "string"
7503
+ },
7504
+ "listId": {
7505
+ "type": "string"
7506
+ },
7507
+ "title": {
7508
+ "type": "string"
7509
+ },
7510
+ "notes": {
7511
+ "type": "string"
7512
+ },
7513
+ "completed": {
7514
+ "type": "boolean"
7515
+ },
7516
+ "revision": {
7517
+ "type": "string",
7518
+ "description": "Omitted when the provider does not supply a revision; writes require it."
7519
+ }
7520
+ },
7521
+ "required": [
7522
+ "reminderId",
7523
+ "listId",
7524
+ "title",
7525
+ "completed"
7526
+ ],
7527
+ "title": "Reminder"
7528
+ }
7529
+ },
7530
+ "required": [
7531
+ "reminder"
7532
+ ],
7533
+ "title": "RemindersProviderInterfaceUpdateReminderResponseMessage"
7253
7534
  }
7254
7535
  }
7255
7536
  ],
@@ -8,7 +8,7 @@
8
8
  {
9
9
  "id": "authentication-and-dcr",
10
10
  "title": "Authentication and dynamic client registration",
11
- "content": "# Authentication and dynamic client registration\n\nAll supported agents use the same OAuth components. REST and MCP select different protected resources; DCR and CIMD select different registration methods. Neither product branding nor registration grants device access.\n\nChoose one reading path. This complete walkthrough already includes discovery, registration, consent, token lifecycle and authorization rules below; you do not need to fetch those component links again. If your connector already implements some steps, read only the missing components instead. Both paths use the same canonical instructions.\n\nFor REST, use the discovered issuer as the OAuth resource. For MCP, use the MCP protected-resource metadata. Keep that choice through authorization, exchange and refresh. If you chose the wrong transport, start a new authorization flow for the correct resource; refresh does not switch audiences.\n\nWalkthrough steps (the linked components are also included below):\n\n1. [Discover endpoints and choose REST or MCP](/docs/for-ai/guides/oauth-discovery.md).\n2. [Register with DCR or supported CIMD](/docs/for-ai/guides/oauth-client-registration.md). Remote callbacks require HTTPS; local callback registrations contain only localhost/loopback callbacks. Repeated canonical fingerprints reuse the original public client without expanding scopes.\n3. [Obtain user consent and validate the callback](/docs/for-ai/guides/oauth-consent-and-callback.md). PKCE S256 is required. Pause for the user to sign in and approve access.\n4. [Exchange, refresh and revoke tokens](/docs/for-ai/guides/oauth-token-lifecycle.md). Keep the same canonical resource through authorization, exchange and refresh.\n5. [Verify the connection](/docs/for-ai/guides/first-setup.md), then use [the REST quickstart](/docs/for-ai/guides/quickstart.md) or your client's MCP tools.\n\nRead [authorization rules](/docs/for-ai/guides/authorization-rules.md) for scopes, principal/resource policies, sharing and denial diagnosis. Never ask for a Google password, paste credentials into chat, or approve the agent's own grant. Claimed client names such as Muse and Grok remain unverified.\n\n## Discover the OAuth server and choose REST or MCP\n\nThis discovery step is shared by every client. The deployed pilot API is https://api.portoperatingsystem.lol. Fetch its /.well-known/oauth-authorization-server document anonymously. Read issuer, authorization_endpoint, token_endpoint, registration_endpoint, revocation_endpoint and scopes_supported. Use the returned endpoints exactly. An alias can advertise a different canonical Cloud Run issuer; do not substitute the alias into token audiences.\n\n| Interface | API destination | OAuth resource |\n| --- | --- | --- |\n| REST | The returned issuer, plus the documented operation path | The exact returned issuer |\n| MCP | The returned issuer plus /mcp, Streamable HTTP | The resource returned by /.well-known/oauth-protected-resource/mcp, normally issuer plus /mcp |\n\nAn MCP connector can start at https://api.portoperatingsystem.lol/mcp and follow its WWW-Authenticate resource_metadata URL. Fetch that public metadata and the authorization server it names. MCP initialization alone does not prove that the account's devices are accessible. Never use a REST token on MCP or an MCP token on REST.\n\nChoose the transport before authorizing. Keep its resource unchanged through authorization, token exchange and refresh. If a REST request fails because you authorized the MCP resource (or the reverse), obtain a new user authorization for the correct resource. Refresh cannot change the token's audience.\n\nChoose one supported [client registration method](/docs/for-ai/guides/oauth-client-registration.md), then follow the same [consent and callback steps](/docs/for-ai/guides/oauth-consent-and-callback.md). If metadata omits registration_endpoint, new DCR registration is unavailable; do not guess a replacement endpoint or silently switch to another client's credentials.\n\nSee [scopes and resource rules](/docs/for-ai/guides/authorization-rules.md). Authorization-server scopes_supported describes server vocabulary; a particular client's accepted scopes can be narrower.\n\n### Carry discovery values into every request\n\nThis JavaScript fragment initializes a REST connection. Keep `authorizationServer` and `resource` for the consent and token examples; the API alias is only the discovery starting point.\n\n```javascript\nconst response = await fetch('https://api.portoperatingsystem.lol/.well-known/oauth-authorization-server');\nif (!response.ok) throw new Error('OAuth discovery failed');\nconst authorizationServer = await response.json();\nconst resource = authorizationServer.issuer;\nconst apiBase = authorizationServer.issuer;\n```\n\nFor MCP, assign `resource` from the protected-resource metadata's `resource` field instead. Do not replace either value with the hostname you started from. A wrong `resource` can produce an `invalid_request` error callback even when client registration succeeded.\n\nCanonical component: [Discover the OAuth server and choose REST or MCP](/docs/for-ai/guides/oauth-discovery.md).\n\n## Register an OAuth client with DCR or CIMD\n\nStart with [discovery](/docs/for-ai/guides/oauth-discovery.md). DCR and CIMD identify a client; they do not sign in a user or grant device access. Both use the same [PKCE consent and callback flow](/docs/for-ai/guides/oauth-consent-and-callback.md) and [token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\n### DCR: public clients\n\nPOST application/json to the discovered registration_endpoint:\n\n```json\n{\"client_name\":\"My device assistant\",\"redirect_uris\":[\"https://your-client.example/oauth/callback\"],\"token_endpoint_auth_method\":\"none\",\"grant_types\":[\"authorization_code\",\"refresh_token\"],\"response_types\":[\"code\"],\"scope\":\"endpoint:read message:send\"}\n```\n\nUse a callback the client controls. Remote callbacks require HTTPS. Local clients may use exact HTTP callbacks on localhost or literal loopback IPs, such as http://127.0.0.1:8765/callback. All callbacks in a registration must be local or all must be remote; these sets cannot be mixed. No fragments or user information are permitted. Start the local callback listener before authorization. The website's client-management interface enforces this same callback-set policy.\n\nSuccess is 201 with client_id, client_id_issued_at and accepted metadata. Public clients get no client_secret. Supported DCR scopes are endpoint:read, endpoint:write, message:read, message:send, group:read, group:manage, subscription:read and subscription:write. The default is endpoint:read. Request only the task's necessary scopes and check the returned scope. Broader static-client scopes are outside this anonymous profile.\n\nThe registration fingerprint is SHA-256 of compact canonical JSON with sorted object keys and sorted redirect_uris, grant_types and response_types arrays, plus client_name and token_endpoint_auth_method. Defaults are applied before hashing. Array ordering does not create another client. A matching registration returns the original client ID, issue time, scopes and descriptive metadata. It never overwrites the existing client or expands scopes, even if scope or software_id differs in the new request. Fingerprinting is deduplication, not proof of callback ownership or vendor identity.\n\nDefault quotas are 1,000 new registrations per rolling day and 10,000 retained registrations. Reuse does not consume new-registration quota. A quota failure returns 429 with Retry-After. An operator can disable new registrations without retiring existing grants. Read the [registration operation](/docs/for-ai/operations/registerDynamicOAuthClient.md) for exact request, response and error schemas.\n\n### CIMD: allowlisted metadata clients\n\nA supported CIMD client uses its allowlisted HTTPS metadata URL as client_id instead of posting a DCR request. Port OS retrieves and validates that client metadata, including its exact callbacks and public PKCE profile. Arbitrary metadata URLs and redirects from the metadata fetch are not supported. If your metadata URL is not allowlisted, arrange onboarding or use DCR if your client supports it. Do not pretend another client's metadata URL belongs to you.\n\nClient_name, software_id, software_version and client_uri remain unverified claims. No trusted software-statement issuer is configured; software_statement is rejected. A registration called Muse or Grok does not establish a verified vendor integration or gain additional permissions. Static confidential clients retain their separately configured client authentication method.\n\nCanonical component: [Register an OAuth client with DCR or CIMD](/docs/for-ai/guides/oauth-client-registration.md).\n\n## Obtain user consent and validate the OAuth callback\n\nUse the endpoints and resource from [discovery](/docs/for-ai/guides/oauth-discovery.md) and the client ID and exact callback from [registration](/docs/for-ai/guides/oauth-client-registration.md). These steps are identical for DCR and CIMD, REST and MCP; the chosen resource is the transport-specific input.\n\n1. Start the callback handler the client controls. For a loopback callback, bind its listener locally before opening authorization.\n2. Generate a cryptographically random PKCE verifier of 43–128 permitted characters. Compute code_challenge = BASE64URL(SHA256(verifier)), without padding. Generate a separate random state and retain both in this authorization attempt.\n3. Open the discovered authorization_endpoint with the following query parameters. Percent-encode parameter values; do not append raw callback URLs or scopes into an unescaped query.\n\n```text\nclient_id=<registered ID or supported CIMD metadata URL>\nredirect_uri=<exact registered callback>\nresponse_type=code\nscope=<requested subset of the client's accepted scopes>\nresource=<chosen canonical REST or MCP resource>\nstate=<random client state>\ncode_challenge=<S256 challenge>\ncode_challenge_method=S256\n```\n\nFor REST, use the `resource = authorizationServer.issuer` value retained from discovery. Construct the URL rather than writing an alias into a template. This JavaScript fragment assumes `clientId`, `redirectUri` and `acceptedScope` come from your registration response and callback configuration:\n\n```javascript\nconst base64url = bytes => btoa(String.fromCharCode(...bytes))\n .replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\nconst verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst state = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst challenge = base64url(new Uint8Array(await crypto.subtle.digest(\n 'SHA-256', new TextEncoder().encode(verifier))));\nconst authorizationURL = new URL(authorizationServer.authorization_endpoint);\nauthorizationURL.search = new URLSearchParams({\n client_id: clientId, redirect_uri: redirectUri, response_type: 'code',\n scope: acceptedScope, resource, state,\n code_challenge: challenge, code_challenge_method: 'S256',\n}).toString();\n// Retain verifier, state and authorizationServer.issuer privately until callback validation.\n// Open authorizationURL.href in the user's browser; wait for their consent.\n```\n\nThe user signs in on Port OS and reviews the requested permissions. Pause for the user; an agent must not approve its own grant, request passwords or manufacture a production sign-in identity. Local functional tests substitute an existing signed fixture identity at this boundary without changing production sign-in.\n\nAfter approval, Port OS navigates to the exact callback with code, state and iss. Reject a callback whose state or issuer does not match this attempt. Treat an error callback as a denied or failed authorization, not a code. Codes and pending consent expire after ten minutes and are single-use. Do not paste codes or credentials into shared chat or logs. Continue with [code exchange and token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\nCanonical component: [Obtain user consent and validate the OAuth callback](/docs/for-ai/guides/oauth-consent-and-callback.md).\n\n## Exchange, refresh and revoke scoped OAuth tokens\n\nComplete [callback validation](/docs/for-ai/guides/oauth-consent-and-callback.md) first. For a public DCR/CIMD client, POST application/x-www-form-urlencoded to the discovered token_endpoint with:\n\n```text\ngrant_type=authorization_code\nclient_id=<client ID used for authorization>\ncode=<validated callback code>\nredirect_uri=<the same exact callback>\ncode_verifier=<this attempt's original verifier>\nresource=<the same canonical resource used for authorization>\n```\n\nContinue with the same discovery values and verifier from the consent example. `code` below must be from a callback whose `state` and `iss` you validated; abort on any callback `error`:\n\n```javascript\nconst tokenResponse = await fetch(authorizationServer.token_endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n grant_type: 'authorization_code', client_id: clientId, code,\n redirect_uri: redirectUri, code_verifier: verifier, resource,\n }),\n});\nif (!tokenResponse.ok) throw new Error('OAuth code exchange failed');\nconst tokens = await tokenResponse.json(); // Store securely; do not print tokens.\n```\n\nSave access_token, refresh_token and returned scope in the connector's secure credential store. Public clients have no client secret. Use Authorization: Bearer <access_token> with REST requests or the MCP HTTP connection, according to that token's resource. A refresh token is never an API credential. [Scopes bound access; resource policies still apply](/docs/for-ai/guides/authorization-rules.md).\n\nRefresh with grant_type=refresh_token, client_id, refresh_token and the original resource at token_endpoint. Scope may stay the same or narrow; it cannot expand. Credentials rotate: store the newly returned refresh token atomically and stop using the previous one. A revoked or reused refresh token must not be retried in a loop. Reauthorize when the grant no longer permits the intended operation.\n\nRevoke by POSTing application/x-www-form-urlencoded token=<refresh_token>&client_id=<client_id> to revocation_endpoint. Revoked grants stop authorizing both access and refresh requests. Removing a local configuration file alone is not server-side revocation.\n\nRead [the token operation](/docs/for-ai/operations/generateToken.md), [revocation operation](/docs/for-ai/operations/revokeOAuthGrant.md), and [connection recovery](/docs/for-ai/guides/troubleshooting.md) for schemas and failures. Verify account access using [first setup](/docs/for-ai/guides/first-setup.md), then perform only the customer's intended task. Dispatch acceptance is distinct from observed device state.\n\nCanonical component: [Exchange, refresh and revoke scoped OAuth tokens](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\n## Scopes and authorization rules\n\nAuthentication establishes the principal and client. OAuth scopes bound the user's delegated authority; resource rules decide which selected resources and actions that principal may access. A scope is not an ownership or sharing grant.\n\nFor delegated REST grants, Port OS verifies token signature, expiry, issuer, REST audience, access-token type and active grant, then checks the operation's scope before existing service resource-policy evaluation. MCP tokens have a separate /mcp audience and cannot be reused on REST. A refresh token is never an API bearer credential.\n\n| Task | Scope |\n| --- | --- |\n| Enumerate or query endpoints/routes | endpoint:read |\n| Modify endpoints/routes | endpoint:write |\n| Send a device message | message:send |\n| Read groups and relationships | group:read |\n| Manage group membership | group:manage |\n| Read subscriptions | subscription:read |\n| Create/update/delete subscriptions | subscription:write |\n\nOther operations are outside the anonymous DCR device profile and fail closed. [Operation pages](/docs/for-ai/operations/index.md) expose exact credential alternatives and resource requirements. [Machine-readable authorization metadata](/docs/references/authorization.yaml) links the contract.\n\nThe existing resource engine converts principal, action, resource and entity data into Cedar requests. Default owner rules and applicable sharing/conditional rules are evaluated; only an Allow outcome admits access. The typed operation IDs come from Port OS's policy action catalog, not invented dotted action names. Owning an endpoint does not override a delegated token's missing scope.\n\nA token with endpoint:read can enumerate permitted lights but cannot dispatch a command. Adding message:send permits dispatch only to endpoints that the signed-in principal's rules allow. An authorized light does not imply camera access. A generic power-capable plug is not automatically a light. For a group request, evaluate the selected targets and report denied or unresolved members separately.\n\nAn invalid/expired/revoked token needs renewed authentication. A scope denial requires the user to approve the needed scope. A resource denial requires the owner to grant the appropriate resource/action access. Never fix denial by switching principal, requesting unrestricted credentials or retrying blindly. Provider authentication failures can require account relinking; they are different from Port OS policy denial. Keep inaccessible resource identities out of diagnostics.\n\nSee [troubleshooting](/docs/for-ai/guides/troubleshooting.md).\n\nCanonical component: [Scopes and authorization rules](/docs/for-ai/guides/authorization-rules.md).\n",
11
+ "content": "# Authentication and dynamic client registration\n\nAll supported agents use the same OAuth components. REST and MCP select different protected resources; DCR and CIMD select different registration methods. Neither product branding nor registration grants device access.\n\nChoose one reading path. This complete walkthrough already includes discovery, registration, consent, token lifecycle and authorization rules below; you do not need to fetch those component links again. If your connector already implements some steps, read only the missing components instead. Both paths use the same canonical instructions.\n\nFor REST, use the discovered issuer as the OAuth resource. For MCP, use the MCP protected-resource metadata. Keep that choice through authorization, exchange and refresh. If you chose the wrong transport, start a new authorization flow for the correct resource; refresh does not switch audiences.\n\nWalkthrough steps (the linked components are also included below):\n\n1. [Discover endpoints and choose REST or MCP](/docs/for-ai/guides/oauth-discovery.md).\n2. [Register with DCR or supported CIMD](/docs/for-ai/guides/oauth-client-registration.md). Remote callbacks require HTTPS; local callback registrations contain only localhost/loopback callbacks. Repeated canonical fingerprints reuse the original public client without expanding scopes.\n3. [Obtain user consent and validate the callback](/docs/for-ai/guides/oauth-consent-and-callback.md). PKCE S256 is required. Pause for the user to sign in and approve access.\n4. [Exchange, refresh and revoke tokens](/docs/for-ai/guides/oauth-token-lifecycle.md). Keep the same canonical resource through authorization, exchange and refresh.\n5. [Verify the connection](/docs/for-ai/guides/first-setup.md), then use [the REST quickstart](/docs/for-ai/guides/quickstart.md) or your client's MCP tools.\n\nRead [authorization rules](/docs/for-ai/guides/authorization-rules.md) for scopes, principal/resource policies, sharing and denial diagnosis. Never ask for a Google password, paste credentials into chat, or approve the agent's own grant. Claimed client names such as Muse and Grok remain unverified.\n\n## Discover the OAuth server and choose REST or MCP\n\nThis discovery step is shared by every client. The deployed pilot API is https://api.portoperatingsystem.lol. Fetch its /.well-known/oauth-authorization-server document anonymously. Read issuer, authorization_endpoint, token_endpoint, registration_endpoint, revocation_endpoint and scopes_supported. Use the returned endpoints exactly. An alias can advertise a different canonical Cloud Run issuer; do not substitute the alias into token audiences.\n\n| Interface | API destination | OAuth resource |\n| --- | --- | --- |\n| REST | The returned issuer, plus the documented operation path | The exact returned issuer |\n| MCP | The returned issuer plus /mcp, Streamable HTTP | The resource returned by /.well-known/oauth-protected-resource/mcp, normally issuer plus /mcp |\n\nAn MCP connector can start at https://api.portoperatingsystem.lol/mcp and follow its WWW-Authenticate resource_metadata URL. Fetch that public metadata and the authorization server it names. MCP initialization alone does not prove that the account's devices are accessible. Never use a REST token on MCP or an MCP token on REST.\n\nChoose the transport before authorizing. Omitting resource at authorization selects REST. Supply the discovered resource explicitly to select MCP. Code exchange and refresh may omit resource and inherit the grant audience; an explicit resource must stay unchanged. If a REST request fails because you authorized the MCP resource (or the reverse), obtain a new user authorization for the correct resource. Refresh cannot change the token's audience.\n\nChoose one supported [client registration method](/docs/for-ai/guides/oauth-client-registration.md), then follow the same [consent and callback steps](/docs/for-ai/guides/oauth-consent-and-callback.md). If metadata omits registration_endpoint, new DCR registration is unavailable; do not guess a replacement endpoint or silently switch to another client's credentials.\n\nSee [scopes and resource rules](/docs/for-ai/guides/authorization-rules.md). Authorization-server scopes_supported describes server vocabulary; a particular client's accepted scopes can be narrower.\n\n### Carry discovery values into every request\n\nThis JavaScript fragment initializes a REST connection. Keep `authorizationServer` and `resource` for the consent and token examples; the API alias is only the discovery starting point.\n\n```javascript\nconst response = await fetch('https://api.portoperatingsystem.lol/.well-known/oauth-authorization-server');\nif (!response.ok) throw new Error('OAuth discovery failed');\nconst authorizationServer = await response.json();\nconst resource = authorizationServer.issuer;\nconst apiBase = authorizationServer.issuer;\n```\n\nFor MCP, assign `resource` from the protected-resource metadata's `resource` field instead. Do not replace either value with the hostname you started from. A wrong `resource` can produce an `invalid_target` error callback even when client registration succeeded.\n\nCanonical component: [Discover the OAuth server and choose REST or MCP](/docs/for-ai/guides/oauth-discovery.md).\n\n## Register an OAuth client with DCR or CIMD\n\nStart with [discovery](/docs/for-ai/guides/oauth-discovery.md). DCR and CIMD identify a client; they do not sign in a user or grant device access. Both use the same [PKCE consent and callback flow](/docs/for-ai/guides/oauth-consent-and-callback.md) and [token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\n### DCR: public clients\n\nPOST application/json to the discovered registration_endpoint:\n\n```json\n{\"client_name\":\"My device assistant\",\"redirect_uris\":[\"https://your-client.example/oauth/callback\"],\"token_endpoint_auth_method\":\"none\",\"grant_types\":[\"authorization_code\",\"refresh_token\"],\"response_types\":[\"code\"],\"scope\":\"endpoint:read message:send\"}\n```\n\nUse a callback the client controls. Remote callbacks require HTTPS. Local clients may use exact HTTP callbacks on localhost or literal loopback IPs, such as http://127.0.0.1:8765/callback. All callbacks in a registration must be local or all must be remote; these sets cannot be mixed. No fragments or user information are permitted. Start the local callback listener before authorization. The website's client-management interface enforces this same callback-set policy.\n\nSuccess is 201 with client_id, client_id_issued_at and accepted metadata. Public clients get no client_secret. Supported DCR scopes are endpoint:read, endpoint:write, message:read, message:send, group:read, group:manage, subscription:read and subscription:write. The default is endpoint:read. Request only the task's necessary scopes and check the returned scope. Broader static-client scopes are outside this anonymous profile.\n\nThe registration fingerprint is SHA-256 of compact canonical JSON with sorted object keys and sorted redirect_uris, grant_types and response_types arrays, plus client_name and token_endpoint_auth_method. Defaults are applied before hashing. Array ordering does not create another client. A matching registration returns the original client ID, issue time, scopes and descriptive metadata. It never overwrites the existing client or expands scopes, even if scope or software_id differs in the new request. Fingerprinting is deduplication, not proof of callback ownership or vendor identity.\n\nDefault quotas are 1,000 new registrations per rolling day and 10,000 retained registrations. Reuse does not consume new-registration quota. A quota failure returns 429 with Retry-After. An operator can disable new registrations without retiring existing grants. Read the [registration operation](/docs/for-ai/operations/registerDynamicOAuthClient.md) for exact request, response and error schemas.\n\n### CIMD: allowlisted metadata clients\n\nA supported CIMD client uses its allowlisted HTTPS metadata URL as client_id instead of posting a DCR request. Port OS retrieves and validates that client metadata, including its exact callbacks and public PKCE profile. Arbitrary metadata URLs and redirects from the metadata fetch are not supported. If your metadata URL is not allowlisted, arrange onboarding or use DCR if your client supports it. Do not pretend another client's metadata URL belongs to you.\n\nClient_name, software_id, software_version and client_uri remain unverified claims. No trusted software-statement issuer is configured; software_statement is rejected. A registration called Muse or Grok does not establish a verified vendor integration or gain additional permissions. Static confidential clients retain their separately configured client authentication method.\n\nCanonical component: [Register an OAuth client with DCR or CIMD](/docs/for-ai/guides/oauth-client-registration.md).\n\n## Obtain user consent and validate the OAuth callback\n\nUse the endpoints and resource from [discovery](/docs/for-ai/guides/oauth-discovery.md) and the client ID and exact callback from [registration](/docs/for-ai/guides/oauth-client-registration.md). These steps are identical for DCR and CIMD, REST and MCP; the chosen resource is the transport-specific input.\n\n`resource` is optional. Omitting it selects the canonical REST audience (the authorization-server issuer). For MCP, supply its discovered `/mcp` resource explicitly. Token exchange and refresh can omit `resource` and inherit the audience bound to the authorization code or refresh token. Explicit mismatches are rejected as `invalid_target`.\n\n1. Start the callback handler the client controls. For a loopback callback, bind its listener locally before opening authorization.\n2. Generate a cryptographically random PKCE verifier of 43–128 permitted characters. Compute code_challenge = BASE64URL(SHA256(verifier)), without padding. Generate a separate random state and retain both in this authorization attempt.\n3. Open the discovered authorization_endpoint with the following query parameters. Percent-encode parameter values; do not append raw callback URLs or scopes into an unescaped query.\n\n```text\nclient_id=<registered ID or supported CIMD metadata URL>\nredirect_uri=<exact registered callback>\nresponse_type=code\nscope=<requested subset of the client's accepted scopes>\nresource=<chosen canonical REST or MCP resource>\nstate=<random client state>\ncode_challenge=<S256 challenge>\ncode_challenge_method=S256\n```\n\nFor REST, use the `resource = authorizationServer.issuer` value retained from discovery. Construct the URL rather than writing an alias into a template. This JavaScript fragment assumes `clientId`, `redirectUri` and `acceptedScope` come from your registration response and callback configuration:\n\n```javascript\nconst base64url = bytes => btoa(String.fromCharCode(...bytes))\n .replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\nconst verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst state = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst challenge = base64url(new Uint8Array(await crypto.subtle.digest(\n 'SHA-256', new TextEncoder().encode(verifier))));\nconst authorizationURL = new URL(authorizationServer.authorization_endpoint);\nauthorizationURL.search = new URLSearchParams({\n client_id: clientId, redirect_uri: redirectUri, response_type: 'code',\n scope: acceptedScope, resource, state,\n code_challenge: challenge, code_challenge_method: 'S256',\n}).toString();\n// Retain verifier, state and authorizationServer.issuer privately until callback validation.\n// Open authorizationURL.href in the user's browser; wait for their consent.\n```\n\nThe user signs in on Port OS and reviews the requested permissions. Pause for the user; an agent must not approve its own grant, request passwords or manufacture a production sign-in identity. Local functional tests substitute an existing signed fixture identity at this boundary without changing production sign-in.\n\nAfter approval, the consent page navigates to a one-time Port OS continuation.\nThat endpoint returns HTTP 303 See Other with the exact registered callback in\nLocation, carrying code, original state and iss. Denial uses the same 303 handoff\nwith access_denied instead of a code. The authenticated consent fetch returns\n200 JSON only for the intermediate continuation; it must be followed by document\nnavigation, not another fetch. Continuations expire after two minutes and are\nsingle-use. They require no login token and cannot be used to approve consent.\n\nReject a callback whose state or issuer does not match this attempt. Treat an\nerror callback as a denied or failed authorization, not a code. Codes and pending\nconsent expire after ten minutes and are single-use. Do not paste codes,\ncontinuation references or credentials into shared chat or logs. Continue with\n[code exchange and token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\nFor hosted-client acceptance, preserve the browser network log and approve a\nfresh request. Verify the document request to /oauth/authorization-response\nreturns 303, the next GET reaches the registered client callback, and the client\nposts its code and original PKCE verifier to the discovered token endpoint.\nRepeat with Deny and verify access_denied without a code. Backend functional and\nwebsite browser tests cover these boundaries against an isolated callback;\ncompatibility with a specific hosted client still requires that live trace.\n\nCanonical component: [Obtain user consent and validate the OAuth callback](/docs/for-ai/guides/oauth-consent-and-callback.md).\n\n## Exchange, refresh and revoke scoped OAuth tokens\n\nComplete [callback validation](/docs/for-ai/guides/oauth-consent-and-callback.md) first. For a public DCR/CIMD client, POST application/x-www-form-urlencoded to the discovered token_endpoint with:\n\n```text\ngrant_type=authorization_code\nclient_id=<client ID used for authorization>\ncode=<validated callback code>\nredirect_uri=<the same exact callback>\ncode_verifier=<this attempt's original verifier>\nresource=<the same canonical resource used for authorization>\n```\n\nContinue with the same discovery values and verifier from the consent example. `code` below must be from a callback whose `state` and `iss` you validated; abort on any callback `error`:\n\n```javascript\nconst tokenResponse = await fetch(authorizationServer.token_endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n grant_type: 'authorization_code', client_id: clientId, code,\n redirect_uri: redirectUri, code_verifier: verifier, resource,\n }),\n});\nif (!tokenResponse.ok) throw new Error('OAuth code exchange failed');\nconst tokens = await tokenResponse.json(); // Store securely; do not print tokens.\n```\n\nSave access_token, refresh_token and returned scope in the connector's secure credential store. Public clients have no client secret. Use Authorization: Bearer <access_token> with REST requests or the MCP HTTP connection, according to that token's resource. A refresh token is never an API credential. [Scopes bound access; resource policies still apply](/docs/for-ai/guides/authorization-rules.md).\n\nRefresh with grant_type=refresh_token, client_id and refresh_token at token_endpoint. The resource parameter is optional for code exchange and refresh: omission inherits the existing grant audience; if supplied, it must match the original resource. Scope may stay the same or narrow; it cannot expand. Credentials rotate: store the newly returned refresh token atomically and stop using the previous one. A revoked or reused refresh token must not be retried in a loop. Reauthorize when the grant no longer permits the intended operation.\n\nRevoke by POSTing application/x-www-form-urlencoded token=<refresh_token>&client_id=<client_id> to revocation_endpoint. Revoked grants stop authorizing both access and refresh requests. Removing a local configuration file alone is not server-side revocation.\n\nRead [the token operation](/docs/for-ai/operations/generateToken.md), [revocation operation](/docs/for-ai/operations/revokeOAuthGrant.md), and [connection recovery](/docs/for-ai/guides/troubleshooting.md) for schemas and failures. Verify account access using [first setup](/docs/for-ai/guides/first-setup.md), then perform only the customer's intended task. Dispatch acceptance is distinct from observed device state.\n\nCanonical component: [Exchange, refresh and revoke scoped OAuth tokens](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\n## Scopes and authorization rules\n\nAuthentication establishes the principal and client. OAuth scopes bound the user's delegated authority; resource rules decide which selected resources and actions that principal may access. A scope is not an ownership or sharing grant.\n\nFor delegated REST grants, Port OS verifies token signature, expiry, issuer, REST audience, access-token type and active grant, then checks the operation's scope before existing service resource-policy evaluation. MCP tokens have a separate /mcp audience and cannot be reused on REST. A refresh token is never an API bearer credential.\n\n| Task | Scope |\n| --- | --- |\n| Enumerate or query endpoints/routes | endpoint:read |\n| Modify endpoints/routes | endpoint:write |\n| Send a device message | message:send |\n| Read groups and relationships | group:read |\n| Manage group membership | group:manage |\n| Read subscriptions | subscription:read |\n| Create/update/delete subscriptions | subscription:write |\n\nOther operations are outside the anonymous DCR device profile and fail closed. [Operation pages](/docs/for-ai/operations/index.md) expose exact credential alternatives and resource requirements. [Machine-readable authorization metadata](/docs/references/authorization.yaml) links the contract.\n\nThe existing resource engine converts principal, action, resource and entity data into Cedar requests. Default owner rules and applicable sharing/conditional rules are evaluated; only an Allow outcome admits access. The typed operation IDs come from Port OS's policy action catalog, not invented dotted action names. Owning an endpoint does not override a delegated token's missing scope.\n\nA token with endpoint:read can enumerate permitted lights but cannot dispatch a command. Adding message:send permits dispatch only to endpoints that the signed-in principal's rules allow. An authorized light does not imply camera access. A generic power-capable plug is not automatically a light. For a group request, evaluate the selected targets and report denied or unresolved members separately.\n\nAn invalid/expired/revoked token needs renewed authentication. A scope denial requires the user to approve the needed scope. A resource denial requires the owner to grant the appropriate resource/action access. Never fix denial by switching principal, requesting unrestricted credentials or retrying blindly. Provider authentication failures can require account relinking; they are different from Port OS policy denial. Keep inaccessible resource identities out of diagnostics.\n\nSee [troubleshooting](/docs/for-ai/guides/troubleshooting.md).\n\nCanonical component: [Scopes and authorization rules](/docs/for-ai/guides/authorization-rules.md).\n",
12
12
  "setupPrompt": null
13
13
  },
14
14
  {
@@ -80,19 +80,19 @@
80
80
  {
81
81
  "id": "oauth-consent-and-callback",
82
82
  "title": "Obtain user consent and validate the OAuth callback",
83
- "content": "# Obtain user consent and validate the OAuth callback\n\nUse the endpoints and resource from [discovery](/docs/for-ai/guides/oauth-discovery.md) and the client ID and exact callback from [registration](/docs/for-ai/guides/oauth-client-registration.md). These steps are identical for DCR and CIMD, REST and MCP; the chosen resource is the transport-specific input.\n\n1. Start the callback handler the client controls. For a loopback callback, bind its listener locally before opening authorization.\n2. Generate a cryptographically random PKCE verifier of 43–128 permitted characters. Compute code_challenge = BASE64URL(SHA256(verifier)), without padding. Generate a separate random state and retain both in this authorization attempt.\n3. Open the discovered authorization_endpoint with the following query parameters. Percent-encode parameter values; do not append raw callback URLs or scopes into an unescaped query.\n\n```text\nclient_id=<registered ID or supported CIMD metadata URL>\nredirect_uri=<exact registered callback>\nresponse_type=code\nscope=<requested subset of the client's accepted scopes>\nresource=<chosen canonical REST or MCP resource>\nstate=<random client state>\ncode_challenge=<S256 challenge>\ncode_challenge_method=S256\n```\n\nFor REST, use the `resource = authorizationServer.issuer` value retained from discovery. Construct the URL rather than writing an alias into a template. This JavaScript fragment assumes `clientId`, `redirectUri` and `acceptedScope` come from your registration response and callback configuration:\n\n```javascript\nconst base64url = bytes => btoa(String.fromCharCode(...bytes))\n .replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\nconst verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst state = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst challenge = base64url(new Uint8Array(await crypto.subtle.digest(\n 'SHA-256', new TextEncoder().encode(verifier))));\nconst authorizationURL = new URL(authorizationServer.authorization_endpoint);\nauthorizationURL.search = new URLSearchParams({\n client_id: clientId, redirect_uri: redirectUri, response_type: 'code',\n scope: acceptedScope, resource, state,\n code_challenge: challenge, code_challenge_method: 'S256',\n}).toString();\n// Retain verifier, state and authorizationServer.issuer privately until callback validation.\n// Open authorizationURL.href in the user's browser; wait for their consent.\n```\n\nThe user signs in on Port OS and reviews the requested permissions. Pause for the user; an agent must not approve its own grant, request passwords or manufacture a production sign-in identity. Local functional tests substitute an existing signed fixture identity at this boundary without changing production sign-in.\n\nAfter approval, Port OS navigates to the exact callback with code, state and iss. Reject a callback whose state or issuer does not match this attempt. Treat an error callback as a denied or failed authorization, not a code. Codes and pending consent expire after ten minutes and are single-use. Do not paste codes or credentials into shared chat or logs. Continue with [code exchange and token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n",
83
+ "content": "# Obtain user consent and validate the OAuth callback\n\nUse the endpoints and resource from [discovery](/docs/for-ai/guides/oauth-discovery.md) and the client ID and exact callback from [registration](/docs/for-ai/guides/oauth-client-registration.md). These steps are identical for DCR and CIMD, REST and MCP; the chosen resource is the transport-specific input.\n\n`resource` is optional. Omitting it selects the canonical REST audience (the authorization-server issuer). For MCP, supply its discovered `/mcp` resource explicitly. Token exchange and refresh can omit `resource` and inherit the audience bound to the authorization code or refresh token. Explicit mismatches are rejected as `invalid_target`.\n\n1. Start the callback handler the client controls. For a loopback callback, bind its listener locally before opening authorization.\n2. Generate a cryptographically random PKCE verifier of 43–128 permitted characters. Compute code_challenge = BASE64URL(SHA256(verifier)), without padding. Generate a separate random state and retain both in this authorization attempt.\n3. Open the discovered authorization_endpoint with the following query parameters. Percent-encode parameter values; do not append raw callback URLs or scopes into an unescaped query.\n\n```text\nclient_id=<registered ID or supported CIMD metadata URL>\nredirect_uri=<exact registered callback>\nresponse_type=code\nscope=<requested subset of the client's accepted scopes>\nresource=<chosen canonical REST or MCP resource>\nstate=<random client state>\ncode_challenge=<S256 challenge>\ncode_challenge_method=S256\n```\n\nFor REST, use the `resource = authorizationServer.issuer` value retained from discovery. Construct the URL rather than writing an alias into a template. This JavaScript fragment assumes `clientId`, `redirectUri` and `acceptedScope` come from your registration response and callback configuration:\n\n```javascript\nconst base64url = bytes => btoa(String.fromCharCode(...bytes))\n .replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\nconst verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst state = base64url(crypto.getRandomValues(new Uint8Array(32)));\nconst challenge = base64url(new Uint8Array(await crypto.subtle.digest(\n 'SHA-256', new TextEncoder().encode(verifier))));\nconst authorizationURL = new URL(authorizationServer.authorization_endpoint);\nauthorizationURL.search = new URLSearchParams({\n client_id: clientId, redirect_uri: redirectUri, response_type: 'code',\n scope: acceptedScope, resource, state,\n code_challenge: challenge, code_challenge_method: 'S256',\n}).toString();\n// Retain verifier, state and authorizationServer.issuer privately until callback validation.\n// Open authorizationURL.href in the user's browser; wait for their consent.\n```\n\nThe user signs in on Port OS and reviews the requested permissions. Pause for the user; an agent must not approve its own grant, request passwords or manufacture a production sign-in identity. Local functional tests substitute an existing signed fixture identity at this boundary without changing production sign-in.\n\nAfter approval, the consent page navigates to a one-time Port OS continuation.\nThat endpoint returns HTTP 303 See Other with the exact registered callback in\nLocation, carrying code, original state and iss. Denial uses the same 303 handoff\nwith access_denied instead of a code. The authenticated consent fetch returns\n200 JSON only for the intermediate continuation; it must be followed by document\nnavigation, not another fetch. Continuations expire after two minutes and are\nsingle-use. They require no login token and cannot be used to approve consent.\n\nReject a callback whose state or issuer does not match this attempt. Treat an\nerror callback as a denied or failed authorization, not a code. Codes and pending\nconsent expire after ten minutes and are single-use. Do not paste codes,\ncontinuation references or credentials into shared chat or logs. Continue with\n[code exchange and token lifecycle](/docs/for-ai/guides/oauth-token-lifecycle.md).\n\nFor hosted-client acceptance, preserve the browser network log and approve a\nfresh request. Verify the document request to /oauth/authorization-response\nreturns 303, the next GET reaches the registered client callback, and the client\nposts its code and original PKCE verifier to the discovered token endpoint.\nRepeat with Deny and verify access_denied without a code. Backend functional and\nwebsite browser tests cover these boundaries against an isolated callback;\ncompatibility with a specific hosted client still requires that live trace.\n",
84
84
  "setupPrompt": null
85
85
  },
86
86
  {
87
87
  "id": "oauth-discovery",
88
88
  "title": "Discover the OAuth server and choose REST or MCP",
89
- "content": "# Discover the OAuth server and choose REST or MCP\n\nThis discovery step is shared by every client. The deployed pilot API is https://api.portoperatingsystem.lol. Fetch its /.well-known/oauth-authorization-server document anonymously. Read issuer, authorization_endpoint, token_endpoint, registration_endpoint, revocation_endpoint and scopes_supported. Use the returned endpoints exactly. An alias can advertise a different canonical Cloud Run issuer; do not substitute the alias into token audiences.\n\n| Interface | API destination | OAuth resource |\n| --- | --- | --- |\n| REST | The returned issuer, plus the documented operation path | The exact returned issuer |\n| MCP | The returned issuer plus /mcp, Streamable HTTP | The resource returned by /.well-known/oauth-protected-resource/mcp, normally issuer plus /mcp |\n\nAn MCP connector can start at https://api.portoperatingsystem.lol/mcp and follow its WWW-Authenticate resource_metadata URL. Fetch that public metadata and the authorization server it names. MCP initialization alone does not prove that the account's devices are accessible. Never use a REST token on MCP or an MCP token on REST.\n\nChoose the transport before authorizing. Keep its resource unchanged through authorization, token exchange and refresh. If a REST request fails because you authorized the MCP resource (or the reverse), obtain a new user authorization for the correct resource. Refresh cannot change the token's audience.\n\nChoose one supported [client registration method](/docs/for-ai/guides/oauth-client-registration.md), then follow the same [consent and callback steps](/docs/for-ai/guides/oauth-consent-and-callback.md). If metadata omits registration_endpoint, new DCR registration is unavailable; do not guess a replacement endpoint or silently switch to another client's credentials.\n\nSee [scopes and resource rules](/docs/for-ai/guides/authorization-rules.md). Authorization-server scopes_supported describes server vocabulary; a particular client's accepted scopes can be narrower.\n\n## Carry discovery values into every request\n\nThis JavaScript fragment initializes a REST connection. Keep `authorizationServer` and `resource` for the consent and token examples; the API alias is only the discovery starting point.\n\n```javascript\nconst response = await fetch('https://api.portoperatingsystem.lol/.well-known/oauth-authorization-server');\nif (!response.ok) throw new Error('OAuth discovery failed');\nconst authorizationServer = await response.json();\nconst resource = authorizationServer.issuer;\nconst apiBase = authorizationServer.issuer;\n```\n\nFor MCP, assign `resource` from the protected-resource metadata's `resource` field instead. Do not replace either value with the hostname you started from. A wrong `resource` can produce an `invalid_request` error callback even when client registration succeeded.\n",
89
+ "content": "# Discover the OAuth server and choose REST or MCP\n\nThis discovery step is shared by every client. The deployed pilot API is https://api.portoperatingsystem.lol. Fetch its /.well-known/oauth-authorization-server document anonymously. Read issuer, authorization_endpoint, token_endpoint, registration_endpoint, revocation_endpoint and scopes_supported. Use the returned endpoints exactly. An alias can advertise a different canonical Cloud Run issuer; do not substitute the alias into token audiences.\n\n| Interface | API destination | OAuth resource |\n| --- | --- | --- |\n| REST | The returned issuer, plus the documented operation path | The exact returned issuer |\n| MCP | The returned issuer plus /mcp, Streamable HTTP | The resource returned by /.well-known/oauth-protected-resource/mcp, normally issuer plus /mcp |\n\nAn MCP connector can start at https://api.portoperatingsystem.lol/mcp and follow its WWW-Authenticate resource_metadata URL. Fetch that public metadata and the authorization server it names. MCP initialization alone does not prove that the account's devices are accessible. Never use a REST token on MCP or an MCP token on REST.\n\nChoose the transport before authorizing. Omitting resource at authorization selects REST. Supply the discovered resource explicitly to select MCP. Code exchange and refresh may omit resource and inherit the grant audience; an explicit resource must stay unchanged. If a REST request fails because you authorized the MCP resource (or the reverse), obtain a new user authorization for the correct resource. Refresh cannot change the token's audience.\n\nChoose one supported [client registration method](/docs/for-ai/guides/oauth-client-registration.md), then follow the same [consent and callback steps](/docs/for-ai/guides/oauth-consent-and-callback.md). If metadata omits registration_endpoint, new DCR registration is unavailable; do not guess a replacement endpoint or silently switch to another client's credentials.\n\nSee [scopes and resource rules](/docs/for-ai/guides/authorization-rules.md). Authorization-server scopes_supported describes server vocabulary; a particular client's accepted scopes can be narrower.\n\n## Carry discovery values into every request\n\nThis JavaScript fragment initializes a REST connection. Keep `authorizationServer` and `resource` for the consent and token examples; the API alias is only the discovery starting point.\n\n```javascript\nconst response = await fetch('https://api.portoperatingsystem.lol/.well-known/oauth-authorization-server');\nif (!response.ok) throw new Error('OAuth discovery failed');\nconst authorizationServer = await response.json();\nconst resource = authorizationServer.issuer;\nconst apiBase = authorizationServer.issuer;\n```\n\nFor MCP, assign `resource` from the protected-resource metadata's `resource` field instead. Do not replace either value with the hostname you started from. A wrong `resource` can produce an `invalid_target` error callback even when client registration succeeded.\n",
90
90
  "setupPrompt": null
91
91
  },
92
92
  {
93
93
  "id": "oauth-token-lifecycle",
94
94
  "title": "Exchange, refresh and revoke scoped OAuth tokens",
95
- "content": "# Exchange, refresh and revoke scoped OAuth tokens\n\nComplete [callback validation](/docs/for-ai/guides/oauth-consent-and-callback.md) first. For a public DCR/CIMD client, POST application/x-www-form-urlencoded to the discovered token_endpoint with:\n\n```text\ngrant_type=authorization_code\nclient_id=<client ID used for authorization>\ncode=<validated callback code>\nredirect_uri=<the same exact callback>\ncode_verifier=<this attempt's original verifier>\nresource=<the same canonical resource used for authorization>\n```\n\nContinue with the same discovery values and verifier from the consent example. `code` below must be from a callback whose `state` and `iss` you validated; abort on any callback `error`:\n\n```javascript\nconst tokenResponse = await fetch(authorizationServer.token_endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n grant_type: 'authorization_code', client_id: clientId, code,\n redirect_uri: redirectUri, code_verifier: verifier, resource,\n }),\n});\nif (!tokenResponse.ok) throw new Error('OAuth code exchange failed');\nconst tokens = await tokenResponse.json(); // Store securely; do not print tokens.\n```\n\nSave access_token, refresh_token and returned scope in the connector's secure credential store. Public clients have no client secret. Use Authorization: Bearer <access_token> with REST requests or the MCP HTTP connection, according to that token's resource. A refresh token is never an API credential. [Scopes bound access; resource policies still apply](/docs/for-ai/guides/authorization-rules.md).\n\nRefresh with grant_type=refresh_token, client_id, refresh_token and the original resource at token_endpoint. Scope may stay the same or narrow; it cannot expand. Credentials rotate: store the newly returned refresh token atomically and stop using the previous one. A revoked or reused refresh token must not be retried in a loop. Reauthorize when the grant no longer permits the intended operation.\n\nRevoke by POSTing application/x-www-form-urlencoded token=<refresh_token>&client_id=<client_id> to revocation_endpoint. Revoked grants stop authorizing both access and refresh requests. Removing a local configuration file alone is not server-side revocation.\n\nRead [the token operation](/docs/for-ai/operations/generateToken.md), [revocation operation](/docs/for-ai/operations/revokeOAuthGrant.md), and [connection recovery](/docs/for-ai/guides/troubleshooting.md) for schemas and failures. Verify account access using [first setup](/docs/for-ai/guides/first-setup.md), then perform only the customer's intended task. Dispatch acceptance is distinct from observed device state.\n",
95
+ "content": "# Exchange, refresh and revoke scoped OAuth tokens\n\nComplete [callback validation](/docs/for-ai/guides/oauth-consent-and-callback.md) first. For a public DCR/CIMD client, POST application/x-www-form-urlencoded to the discovered token_endpoint with:\n\n```text\ngrant_type=authorization_code\nclient_id=<client ID used for authorization>\ncode=<validated callback code>\nredirect_uri=<the same exact callback>\ncode_verifier=<this attempt's original verifier>\nresource=<the same canonical resource used for authorization>\n```\n\nContinue with the same discovery values and verifier from the consent example. `code` below must be from a callback whose `state` and `iss` you validated; abort on any callback `error`:\n\n```javascript\nconst tokenResponse = await fetch(authorizationServer.token_endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n grant_type: 'authorization_code', client_id: clientId, code,\n redirect_uri: redirectUri, code_verifier: verifier, resource,\n }),\n});\nif (!tokenResponse.ok) throw new Error('OAuth code exchange failed');\nconst tokens = await tokenResponse.json(); // Store securely; do not print tokens.\n```\n\nSave access_token, refresh_token and returned scope in the connector's secure credential store. Public clients have no client secret. Use Authorization: Bearer <access_token> with REST requests or the MCP HTTP connection, according to that token's resource. A refresh token is never an API credential. [Scopes bound access; resource policies still apply](/docs/for-ai/guides/authorization-rules.md).\n\nRefresh with grant_type=refresh_token, client_id and refresh_token at token_endpoint. The resource parameter is optional for code exchange and refresh: omission inherits the existing grant audience; if supplied, it must match the original resource. Scope may stay the same or narrow; it cannot expand. Credentials rotate: store the newly returned refresh token atomically and stop using the previous one. A revoked or reused refresh token must not be retried in a loop. Reauthorize when the grant no longer permits the intended operation.\n\nRevoke by POSTing application/x-www-form-urlencoded token=<refresh_token>&client_id=<client_id> to revocation_endpoint. Revoked grants stop authorizing both access and refresh requests. Removing a local configuration file alone is not server-side revocation.\n\nRead [the token operation](/docs/for-ai/operations/generateToken.md), [revocation operation](/docs/for-ai/operations/revokeOAuthGrant.md), and [connection recovery](/docs/for-ai/guides/troubleshooting.md) for schemas and failures. Verify account access using [first setup](/docs/for-ai/guides/first-setup.md), then perform only the customer's intended task. Dispatch acceptance is distinct from observed device state.\n",
96
96
  "setupPrompt": null
97
97
  },
98
98
  {