Skip to main content
Glama
Nikhil-Patil-RI

Github-Oauth MCP Server

get_access_token_from_code

Exchange an authorization code for an access token to authenticate with GitHub using OAuth protocol.

Instructions

Exchange authorization code for an access token.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The main handler function for the 'get_access_token_from_code' tool. It is decorated with @mcp.tool() for registration and implements the OAuth token exchange using HTTP POST to GitHub's access_token endpoint.
    @mcp.tool() async def get_access_token_from_code(code: str) -> str: """Exchange authorization code for an access token.""" global access_token url = "https://github.com/login/oauth/access_token" headers = {"Accept": "application/json"} params = { "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "code": code, "redirect_uri": REDIRECT_URI, } async with httpx.AsyncClient() as client: try: response = await client.post(url, headers=headers, params=params, timeout=30.0) response.raise_for_status() data = response.json() access_token = data.get("access_token", "") if access_token: return "Authorization successful! Access token obtained." return "Failed to obtain access token." except Exception as e: print(f"Error fetching access token: {e}") return "Failed to fetch access token."

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nikhil-Patil-RI/MCP-Github-Oauth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server