OAuth-Client registrieren
Registriert einen OAuth-Client dynamisch gemäß RFC 7591.
curl -X POST "https://api.example.com/mcp-server/register" \
-H "Content-Type: application/json" \
-d '{
"redirect_uris": [
"https://client.example.app/callback"
],
"client_name": "Example MCP Client",
"grant_types": [
"authorization_code",
"refresh_token"
],
"token_endpoint_auth_method": "none"
}'
import requests
import json
url = "https://api.example.com/mcp-server/register"
headers = {
"Content-Type": "application/json"
}
data = {
"redirect_uris": [
"https://client.example.app/callback"
],
"client_name": "Example MCP Client",
"grant_types": [
"authorization_code",
"refresh_token"
],
"token_endpoint_auth_method": "none"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.example.com/mcp-server/register", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"redirect_uris": [
"https://client.example.app/callback"
],
"client_name": "Example MCP Client",
"grant_types": [
"authorization_code",
"refresh_token"
],
"token_endpoint_auth_method": "none"
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"redirect_uris": [
"https://client.example.app/callback"
],
"client_name": "Example MCP Client",
"grant_types": [
"authorization_code",
"refresh_token"
],
"token_endpoint_auth_method": "none"
}`)
req, err := http.NewRequest("POST", "https://api.example.com/mcp-server/register", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.example.com/mcp-server/register')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request.body = '{
"redirect_uris": [
"https://client.example.app/callback"
],
"client_name": "Example MCP Client",
"grant_types": [
"authorization_code",
"refresh_token"
],
"token_endpoint_auth_method": "none"
}'
response = http.request(request)
puts response.body
{
"client_id": "mcp_client_example_1234567890abcdef",
"client_id_issued_at": 1735689600,
"redirect_uris": [
"https://client.example.app/callback"
],
"grant_types": [
"authorization_code",
"refresh_token"
],
"response_types": [
"code"
],
"token_endpoint_auth_method": "none",
"client_name": "Example MCP Client"
}
{
"error": "invalid_request",
"error_description": "Missing required field redirect_uris."
}
{
"error": "invalid_redirect_uri",
"error_description": "One or more redirect URIs are invalid."
}
{
"error": "server_error",
"error_description": "An unexpected server error occurred."
}
POST
/register
POST
Base URLstring
Target server for requests. Edit to use your own host.
Content-Typestring
RequiredThe media type of the request body
Options: application/json
redirect_urisarray
RequiredZulässige Redirect-URIs für den Client.
client_namestring
Menschenlesbarer Name des Clients.
grant_typesarray
Vom Client angeforderte OAuth-Grant-Typen.
token_endpoint_auth_methodstring
Client-Authentifizierungsmethode am Token-Endpunkt.
Options: none, client_secret_post
Request Preview
Response
Response will appear here after sending the request
Body
application/json
redirect_urisarray
RequiredZulässige Redirect-URIs für den Client.
Example:
["https://client.example.app/callback"]grant_typesarray
Vom Client angeforderte OAuth-Grant-Typen.
Example:
["authorization_code","refresh_token"]token_endpoint_auth_methodstring
Client-Authentifizierungsmethode am Token-Endpunkt.
Allowed values:
noneclient_secret_postResponses
Was this page helpful?