import requests
url = "https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback"
payload = {
"code": "<string>",
"state": "<string>",
"redirect_uri": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', state: '<string>', redirect_uri: '<string>'})
};
fetch('https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"state": "<string>",
"redirect_uri": "<string>"
}
'{
"object": "mcp_oauth_callback",
"oauth_configured": true,
"tools_synced": true,
"message": "<string>"
}{
"status_code": 123,
"error": "mcp_oauth_requires_user_principal",
"message": "<string>",
"retryable": false,
"statusCode": 123,
"mitigation": "<string>",
"details": {}
}{
"status_code": 123,
"error": "rate_limit_exceeded",
"message": "<string>",
"retryable": true,
"statusCode": 123,
"mitigation": "<string>",
"details": {
"reason": "<string>"
}
}Complete MCP OAuth flow
Complete an OAuth authorization flow for a registered MCP server by exchanging the authorization code returned from the OAuth provider. Requires a user-scoped API key (dg_live_); service keys (dg_svc_) are rejected with mcp_oauth_requires_user_principal.
import requests
url = "https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback"
payload = {
"code": "<string>",
"state": "<string>",
"redirect_uri": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', state: '<string>', redirect_uri: '<string>'})
};
fetch('https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.datagrid.com/v1/organization/mcp-servers/{server_id}/oauth-callback \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"state": "<string>",
"redirect_uri": "<string>"
}
'{
"object": "mcp_oauth_callback",
"oauth_configured": true,
"tools_synced": true,
"message": "<string>"
}{
"status_code": 123,
"error": "mcp_oauth_requires_user_principal",
"message": "<string>",
"retryable": false,
"statusCode": 123,
"mitigation": "<string>",
"details": {}
}{
"status_code": 123,
"error": "rate_limit_exceeded",
"message": "<string>",
"retryable": true,
"statusCode": 123,
"mitigation": "<string>",
"details": {
"reason": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the MCP server.
Body
Authorization code returned by the OAuth authorization server on the callback.
4096The state value the OAuth authorization server echoed on the callback. Must match the value returned from start-oauth.
512The same redirect_uri passed to start-oauth. HTTPS is required except for loopback (http://localhost, http://127.0.0.1, http://[::1]).
2048Response
OAuth flow completed
mcp_oauth_callback Always true when the endpoint returns success; the flow only completes if the token exchange succeeded.
true True if Datagrid automatically re-synced the MCP server's tool manifest after the OAuth exchange. False if the caller lacks organization-edit permissions or the sync itself failed.
Human-readable outcome. Optional product copy — branch on oauth_configured and tools_synced rather than matching this text.