cURL
curl -i -X POST 'https://social2api.com/oauth/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-binary 'grant_type=authorization_code&client_id=client_4a5076aa-f9ab-46e6-b383-7b1374392dc4&code=%3Cauthorization+code%3E&redirect_uri=https%3A%2F%2Fexample.com%2Foauth%2Fcallback&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&resource=https%3A%2F%2Fsocial2api.com%2Fmcp'
Python
from urllib.error import HTTPError
from urllib.request import Request, urlopen
request = Request(
"https://social2api.com/oauth/token",
method="POST",
headers={
"Content-Type": "application/x-www-form-urlencoded",
},
data="grant_type=authorization_code&client_id=client_4a5076aa-f9ab-46e6-b383-7b1374392dc4&code=%3Cauthorization+code%3E&redirect_uri=https%3A%2F%2Fexample.com%2Foauth%2Fcallback&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&resource=https%3A%2F%2Fsocial2api.com%2Fmcp".encode("utf-8"),
)
send = urlopen
try:
with send(request) as response:
print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
print(error.code, error.read().decode("utf-8"))
JavaScript
const response = await fetch("/oauth/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
"grant_type": "authorization_code",
"client_id": "client_4a5076aa-f9ab-46e6-b383-7b1374392dc4",
"code": "<authorization code>",
"redirect_uri": "https://example.com/oauth/callback",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"resource": "https://social2api.com/mcp"
}),
});
console.log(response.status, await response.text());