MetriBeacon
Menu

POST Exchange an authorization code for an MCP access token

/oauth/token

Accepts application/x-www-form-urlencoded authorization_code, client_id, redirect_uri, code_verifier and resource. Codes are single-use; access tokens last 15 minutes and no refresh token is issued. All form fields occur exactly once. The code expires after five minutes, is consumed once, and is bound to the exact client, redirect, resource and S256 verifier. The resulting Bearer token expires after 900 seconds. No refresh token is issued.

On this page

Access and permissions

Accepts application/x-www-form-urlencoded authorization_code, client_id, redirect_uri, code_verifier and resource. Codes are single-use; access tokens last 15 minutes and no refresh token is issued. All form fields occur exactly once. The code expires after five minutes, is consumed once, and is bound to the exact client, redirect, resource and S256 verifier. The resulting Bearer token expires after 900 seconds. No refresh token is issued.

No account sign-in is required. Any listed browser-origin checks and rate limits still apply.

Parameters and headers

No path, query or additional request-header parameters.

Request body

FieldType and limitsRequiredMeaning
$object | objectYes—
$.client_idstring; {"minLength":1}YesOAuth client identifier returned by public client registration.
$.codestring; {"maxLength":64,"minLength":64}No—
$.code_verifierstring; {"pattern":"^[A-Za-z0-9._~-]{43,128}$"}NoOriginal high-entropy PKCE verifier for this authorization request. Keep it private until token exchange.
$.grant_typestring; {"enum":["authorization_code","refresh_token"]}Yes—
$.redirect_uristring; {"format":"uri"}NoExact registered callback URI; it must remain identical across authorization and token exchange.
$.resourcestring; {"enum":["https://metribeacon.com/mcp","https://metribeacon.com/mcp/catalog"]}NoCanonical protected resource URI. MCP access tokens are bound to this resource.
$.refresh_tokenstring; {"minLength":68,"maxLength":68}No—
$.scopestringNo—
$ (oneOf 1)objectNo—
$ (oneOf 1).grant_typeJSON; {"const":"authorization_code"}No—
$ (oneOf 1).codestring; {"maxLength":64,"minLength":64}Yes—
$ (oneOf 1).code_verifierstring; {"pattern":"^[A-Za-z0-9._~-]{43,128}$"}YesOriginal high-entropy PKCE verifier for this authorization request. Keep it private until token exchange.
$ (oneOf 1).redirect_uristring; {"format":"uri"}YesExact registered callback URI; it must remain identical across authorization and token exchange.
$ (oneOf 1).resourcestring; {"enum":["https://metribeacon.com/mcp","https://metribeacon.com/mcp/catalog"]}YesCanonical protected resource URI. MCP access tokens are bound to this resource.
$ (oneOf 2)objectNo—
$ (oneOf 2).grant_typeJSON; {"const":"refresh_token"}No—
$ (oneOf 2).refresh_tokenstring; {"minLength":68,"maxLength":68}Yes—

Responses

HeaderType and limitsMeaning
Cache-Controlstring; {"pattern":"(?:^|,\\s*)no-store(?:,|$)"}Private API responses prohibit storage. Public OAuth metadata is cached for 300 seconds; live streams additionally prohibit transformation.
Content-Languagestring; {"enum":["en","de"]}Language of human-readable response text, resolved from Accept-Language or the documented browser preference. Technical codes and identifiers remain stable.
Referrer-PolicyJSON; {"enum":["strict-origin-when-cross-origin","no-referrer"]}The default referrer policy is strict-origin-when-cross-origin. Provider-login responses use no-referrer to protect login parameters.
VarystringResponses vary by Accept-Language; browser-rendered responses can also vary by the preference cookie.
X-Content-Type-OptionsJSON; {"const":"nosniff"}The browser must use the declared content type.
X-Frame-OptionsJSON; {"const":"DENY"}The response must not be embedded in a frame.
X-Request-IDstringServer-generated request identifier. Include this when reporting an error; inbound values are not trusted.

application/json

FieldType and limitsRequiredMeaning
$objectYes—
$.access_tokenstringYesShort-lived Bearer credential for the canonical MCP resource. Do not log or publish it.
$.expires_inintegerYesToken lifetime in seconds from issuance.
$.scopestringYesSpace-separated OAuth scope identifiers. Consent and token permissions are restricted to the selected scopes.
$.token_typestringYesToken authorization scheme, Bearer.
$.refresh_tokenstringNo—
$.connection_idstring; {"format":"uuid"}No—
json
{
  "access_token": "demo",
  "expires_in": 0,
  "scope": "demo",
  "token_type": "demo"
}
Stable error codes
invalid_grant
invalid_peer
HeaderType and limitsMeaning
Cache-Controlstring; {"pattern":"(?:^|,\\s*)no-store(?:,|$)"}Private API responses prohibit storage. Public OAuth metadata is cached for 300 seconds; live streams additionally prohibit transformation.
Content-Languagestring; {"enum":["en","de"]}Language of human-readable response text, resolved from Accept-Language or the documented browser preference. Technical codes and identifiers remain stable.
Referrer-PolicyJSON; {"enum":["strict-origin-when-cross-origin","no-referrer"]}The default referrer policy is strict-origin-when-cross-origin. Provider-login responses use no-referrer to protect login parameters.
VarystringResponses vary by Accept-Language; browser-rendered responses can also vary by the preference cookie.
X-Content-Type-OptionsJSON; {"const":"nosniff"}The browser must use the declared content type.
X-Frame-OptionsJSON; {"const":"DENY"}The response must not be embedded in a frame.
X-Request-IDstringServer-generated request identifier. Include this when reporting an error; inbound values are not trusted.

application/problem+json

FieldType and limitsRequiredMeaning
$ProblemYes—
$.codestringYesStable machine-readable error code
$.detailstringYesShort localized explanation without internal error details
$.instancestringYesUnique relative identifier /api/v1/requests/{request_id}; not a retrievable resource
$.messagestringYesTemporarily identical to detail for existing clients
$.message_keystringYesStable translation key for changing the displayed language without another request
$.message_paramsobject; {"additionalProperties":true}YesNamed, safely rendered message parameters; never arbitrary HTML
$.request_idstring; {"pattern":"^[0-9a-f]{32}$"}YesServer-generated diagnostic identifier. It contains no login token or credential.
$.statusinteger; {"maximum":599,"minimum":400}Yes—
$.titlestringYesLocalized HTTP status title
$.typestring; {"const":"about:blank"}Yes—
json
{
  "code": "demo",
  "detail": "Demo error detail; inspect the documented code.",
  "instance": "demo",
  "message": "Demo error detail; inspect the documented code.",
  "message_key": "errors.requestFailed",
  "message_params": {},
  "request_id": "00000000000000000000000000000000",
  "status": 400,
  "title": "Demo error",
  "type": "about:blank"
}
Stable error codes
rate_limited
HeaderType and limitsMeaning
Cache-Controlstring; {"pattern":"(?:^|,\\s*)no-store(?:,|$)"}Private API responses prohibit storage. Public OAuth metadata is cached for 300 seconds; live streams additionally prohibit transformation.
Content-Languagestring; {"enum":["en","de"]}Language of human-readable response text, resolved from Accept-Language or the documented browser preference. Technical codes and identifiers remain stable.
Referrer-PolicyJSON; {"enum":["strict-origin-when-cross-origin","no-referrer"]}The default referrer policy is strict-origin-when-cross-origin. Provider-login responses use no-referrer to protect login parameters.
Retry-Afterstring; {"pattern":"^[0-9]+$"}Seconds before retry. Preserve supported idempotency identifiers and respect the operation’s mutation semantics.
VarystringResponses vary by Accept-Language; browser-rendered responses can also vary by the preference cookie.
X-Content-Type-OptionsJSON; {"const":"nosniff"}The browser must use the declared content type.
X-Frame-OptionsJSON; {"const":"DENY"}The response must not be embedded in a frame.
X-Request-IDstringServer-generated request identifier. Include this when reporting an error; inbound values are not trusted.

application/problem+json

FieldType and limitsRequiredMeaning
$ProblemYes—
$.codestringYesStable machine-readable error code
$.detailstringYesShort localized explanation without internal error details
$.instancestringYesUnique relative identifier /api/v1/requests/{request_id}; not a retrievable resource
$.messagestringYesTemporarily identical to detail for existing clients
$.message_keystringYesStable translation key for changing the displayed language without another request
$.message_paramsobject; {"additionalProperties":true}YesNamed, safely rendered message parameters; never arbitrary HTML
$.request_idstring; {"pattern":"^[0-9a-f]{32}$"}YesServer-generated diagnostic identifier. It contains no login token or credential.
$.statusinteger; {"maximum":599,"minimum":400}Yes—
$.titlestringYesLocalized HTTP status title
$.typestring; {"const":"about:blank"}Yes—
json
{
  "code": "demo",
  "detail": "Demo error detail; inspect the documented code.",
  "instance": "demo",
  "message": "Demo error detail; inspect the documented code.",
  "message_key": "errors.requestFailed",
  "message_params": {},
  "request_id": "00000000000000000000000000000000",
  "status": 429,
  "title": "Demo error",
  "type": "about:blank"
}
Stable error codes
feature_unavailable
unavailable
HeaderType and limitsMeaning
Cache-Controlstring; {"pattern":"(?:^|,\\s*)no-store(?:,|$)"}Private API responses prohibit storage. Public OAuth metadata is cached for 300 seconds; live streams additionally prohibit transformation.
Content-Languagestring; {"enum":["en","de"]}Language of human-readable response text, resolved from Accept-Language or the documented browser preference. Technical codes and identifiers remain stable.
Referrer-PolicyJSON; {"enum":["strict-origin-when-cross-origin","no-referrer"]}The default referrer policy is strict-origin-when-cross-origin. Provider-login responses use no-referrer to protect login parameters.
Retry-Afterstring; {"pattern":"^[0-9]+$"}Seconds before retry. Preserve supported idempotency identifiers and respect the operation’s mutation semantics.
VarystringResponses vary by Accept-Language; browser-rendered responses can also vary by the preference cookie.
X-Content-Type-OptionsJSON; {"const":"nosniff"}The browser must use the declared content type.
X-Frame-OptionsJSON; {"const":"DENY"}The response must not be embedded in a frame.
X-Request-IDstringServer-generated request identifier. Include this when reporting an error; inbound values are not trusted.

application/problem+json

FieldType and limitsRequiredMeaning
$ProblemYes—
$.codestringYesStable machine-readable error code
$.detailstringYesShort localized explanation without internal error details
$.instancestringYesUnique relative identifier /api/v1/requests/{request_id}; not a retrievable resource
$.messagestringYesTemporarily identical to detail for existing clients
$.message_keystringYesStable translation key for changing the displayed language without another request
$.message_paramsobject; {"additionalProperties":true}YesNamed, safely rendered message parameters; never arbitrary HTML
$.request_idstring; {"pattern":"^[0-9a-f]{32}$"}YesServer-generated diagnostic identifier. It contains no login token or credential.
$.statusinteger; {"maximum":599,"minimum":400}Yes—
$.titlestringYesLocalized HTTP status title
$.typestring; {"const":"about:blank"}Yes—
json
{
  "code": "demo",
  "detail": "Demo error detail; inspect the documented code.",
  "instance": "demo",
  "message": "Demo error detail; inspect the documented code.",
  "message_key": "errors.requestFailed",
  "message_params": {},
  "request_id": "00000000000000000000000000000000",
  "status": 503,
  "title": "Demo error",
  "type": "about:blank"
}

Retries and asynchronous work

This change does not have a general retry guarantee. If the response is unclear, read the affected resource before trying again. Follow Retry-After waiting times and request new sign-in or action codes when they expire.

Request examples

Replace demo IDs, timestamps and placeholders with your own values. For a retry, keep the same IDs, time and content. These examples do not run requests on this page.

Keep login links, codes, cookies and keys private. Do not print them in logs or share them in support requests.

shell
curl --silent --show-error --output /dev/null --write-out "%{http_code}\n" \
  --request POST \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-binary 'client_id=demo&code=demoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code_verifier=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&resource=https%3A%2F%2Fmetribeacon.com%2Fmcp' \
  "https://metribeacon.com/oauth/token"
python
import json
from pathlib import Path
from urllib.request import Request, HTTPRedirectHandler, build_opener
from urllib.error import HTTPError

headers = {}
headers["Content-Type"] = "application/x-www-form-urlencoded"
request = Request("https://metribeacon.com/oauth/token", data="client_id=demo&code=demoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code_verifier=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&resource=https%3A%2F%2Fmetribeacon.com%2Fmcp".encode("utf-8"), headers=headers, method="POST")
class NoRedirect(HTTPRedirectHandler):
    def redirect_request(self, request, fp, code, message, headers, target):
        return None

opener = build_opener(NoRedirect())
try:
    with opener.open(request, timeout=10) as response:
        print(response.status)
except HTTPError as error:
    print(error.code)
    error.close()
javascript
import { readFile } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path";

const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
const response = await fetch("https://metribeacon.com/oauth/token", {
  method: "POST", headers, redirect: "manual",
  signal: AbortSignal.timeout(10000), body: "client_id=demo&code=demoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code_verifier=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&resource=https%3A%2F%2Fmetribeacon.com%2Fmcp",
});
console.log(response.status);
await response.body?.cancel();
go
package main

import (
  "fmt"
  "net/http"
  "time"
  "strings"
)

func main() {
  request, err := http.NewRequest("POST", "https://metribeacon.com/oauth/token", strings.NewReader("client_id=demo&code=demoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code_verifier=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&resource=https%3A%2F%2Fmetribeacon.com%2Fmcp"))
  if err != nil { panic("request failed; credentials and response omitted") }
  request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
  client := &http.Client{Timeout: 10*time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
  response, err := client.Do(request)
  if err != nil { panic("request failed; credentials and response omitted") }
  defer response.Body.Close()
  fmt.Println(response.StatusCode)
}
  • HTTP API, OAuth and MCP

    Find the user API endpoints, their permissions, fields, examples and response formats.

  • GET Request or confirm OAuth consent

    GET prepares explicit browser consent after sign-in. POST confirms one pending consent request using Origin and CSRF. Requires PKCE S256, an exact registered redirect and the canonical /mcp resource; codes expire after five minutes. Required query parameters occur exactly once. URI length is limited to 2048 bytes. The redirect must exactly match a registered HTTPS or loopback URI. Supported scopes: account:read, config:read, config:write, telemetry:read.

  • POST Request or confirm OAuth consent

    GET prepares explicit browser consent after sign-in. POST confirms one pending consent request using Origin and CSRF. Requires PKCE S256, an exact registered redirect and the canonical /mcp resource; codes expire after five minutes. The CSRF value is supplied as form field csrf_token and must match the __Host-mb_csrf cookie and this session. Consent is consumed once; an authorization code is issued only for approve.

  • POST Register a public OAuth client

    Registers a public client with token_endpoint_auth_method none and authorization_code only. HTTPS redirect URIs and explicit loopback redirects are validated; registration is rate-limited.