Skip to main content
Glama

whoop-exchange-code-for-token

Exchange an OAuth authorization code for an access token to authenticate with WHOOP fitness and health data APIs.

Instructions

Exchange authorization code for access token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAuthorization code from OAuth callback

Implementation Reference

  • MCP tool handler for 'whoop-exchange-code-for-token': validates 'code' argument and calls WhoopApiClient.exchangeCodeForToken, returning JSON stringified result.
    case 'whoop-exchange-code-for-token': { if (!args || typeof args.code !== 'string') { throw new Error('code is required and must be a string'); } const result = await this.whoopClient.exchangeCodeForToken(args.code); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Registers the 'whoop-exchange-code-for-token' tool in the listTools response, including name, description, and input schema.
    { name: 'whoop-exchange-code-for-token', description: 'Exchange authorization code for access token', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Authorization code from OAuth callback', }, }, required: ['code'], }, },
  • Core implementation: exchanges OAuth code for access/refresh tokens by sending POST request to Whoop's token endpoint with client credentials.
    async exchangeCodeForToken(code: string): Promise<{ access_token: string; refresh_token: string; expires_in: number }> { const formData = new URLSearchParams(); formData.append('client_id', this.config.clientId); formData.append('client_secret', this.config.clientSecret); formData.append('code', code); formData.append('grant_type', 'authorization_code'); formData.append('redirect_uri', this.config.redirectUri); const response = await axios.post('https://api.prod.whoop.com/oauth/oauth2/token', formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); return response.data; }

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/nissand/whoop-mcp-server-claude'

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