Discovery, registration, authorization, tokens and revocation.
MCP clients find everything on this page on their own. It is here for anyone building a client.
Endpoints
| Endpoint | Method and URL |
|---|---|
| Protected resource metadata | GEThttps://ads.drefly.pro/.well-known/oauth-protected-resource/api/ads/mcp |
| Authorization server metadata | GEThttps://ads.drefly.pro/.well-known/oauth-authorization-server |
| Client registration | POSThttps://ads.drefly.pro/api/ads/oauth/register |
| Authorization | GEThttps://ads.drefly.pro/api/ads/oauth/authorize |
| Token | POSThttps://ads.drefly.pro/api/ads/oauth/token |
| Revocation | POSThttps://ads.drefly.pro/api/ads/oauth/revoke |
Discovery
An MCP request without a token returns 401 with a WWW-Authenticate header that points to the protected resource metadata.
WWW-Authenticate: Bearer realm="drefly-ads", resource_metadata="https://ads.drefly.pro/.well-known/oauth-protected-resource/api/ads/mcp"
Register a client
Clients are public, so token_endpoint_auth_method is always none. Redirect addresses must be https, a loopback address such as http://127.0.0.1:PORT/callback (any port matches), or an app link such as cursor://. Up to 5 addresses per client.
curl -X POST https://ads.drefly.pro/api/ads/oauth/register \
-H "Content-Type: application/json" \
-d '{"client_name":"Nova ads bot","redirect_uris":["http://127.0.0.1:8765/callback"]}' Authorize
Send the owner to the authorization URL. PKCE with S256 is required. The resource parameter, when sent, must be the server URL. The owner approves on Drefly Ads, then returns to your redirect address with code, state and iss.
https://ads.drefly.pro/api/ads/oauth/authorize?response_type=code &client_id=drc_... &redirect_uri=http%3A%2F%2F127.0.0.1%3A8765%2Fcallback &code_challenge=BASE64URL_SHA256_OF_VERIFIER &code_challenge_method=S256 &scope=read%20write &state=random &resource=https%3A%2F%2Fads.drefly.pro%2Fapi%2Fads%2Fmcp
Exchange the code
curl -X POST https://ads.drefly.pro/api/ads/oauth/token \ -d grant_type=authorization_code \ -d code=CODE_FROM_REDIRECT \ -d code_verifier=YOUR_VERIFIER \ -d client_id=drc_... \ -d redirect_uri=http://127.0.0.1:8765/callback
{
"access_token": "dro_...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "drr_...",
"scope": "read write"
}Refresh and revoke
Refresh tokens work once and are replaced on every refresh. Sending a used refresh token again revokes the connection. Revoking a refresh token disconnects the app.
curl -X POST https://ads.drefly.pro/api/ads/oauth/token \ -d grant_type=refresh_token -d refresh_token=drr_... -d client_id=drc_... curl -X POST https://ads.drefly.pro/api/ads/oauth/revoke \ -d token=drr_... -d client_id=drc_...
Lifetimes
| Item | Lifetime |
|---|---|
| Connection page | 10 minutes, used once |
| Authorization code | 5 minutes, used once |
| Access token | 60 minutes |
| Refresh token | Until the connection expires, used once |
| Connection | 7, 30 or 90 days, chosen by the owner |
Next steps
Thanks for the feedback. Tell us what was missing