get_authorization_url
Generate an OAuth2 authorization URL to authenticate with Withings Health API for accessing body measurements, activity tracking, and health data.
Instructions
Get OAuth2 authorization URL to authenticate with Withings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | OAuth scopes (comma-separated): user.info, user.metrics, user.activity | user.info,user.metrics,user.activity |
Implementation Reference
- src/withings_mcp_server/auth.py:62-72 (handler)Core implementation of get_authorization_url: constructs the OAuth2 authorization URL using client credentials and provided scope.def get_authorization_url(self, scope: str = "user.info,user.metrics,user.activity") -> str: """Generate OAuth2 authorization URL.""" params = { "response_type": "code", "client_id": self.client_id, "redirect_uri": self.redirect_uri, "scope": scope, "state": "random_state_string" } query = "&".join(f"{k}={v}" for k, v in params.items()) return f"{self.AUTH_URL}?{query}"
- Input schema for the get_authorization_url tool, defining the optional 'scope' parameter.inputSchema={ "type": "object", "properties": { "scope": { "type": "string", "description": "OAuth scopes (comma-separated): user.info, user.metrics, user.activity", "default": "user.info,user.metrics,user.activity", }, }, },
- src/withings_mcp_server/server.py:175-188 (registration)Tool registration in the MCP server's list_tools() method.Tool( name="get_authorization_url", description="Get OAuth2 authorization URL to authenticate with Withings", inputSchema={ "type": "object", "properties": { "scope": { "type": "string", "description": "OAuth scopes (comma-separated): user.info, user.metrics, user.activity", "default": "user.info,user.metrics,user.activity", }, }, }, ),
- MCP call_tool dispatch handler for get_authorization_url, which calls the auth method and returns formatted response.if name == "get_authorization_url": scope = arguments.get("scope", "user.info,user.metrics,user.activity") url = self.auth.get_authorization_url(scope) return [ TextContent( type="text", text=f"Please visit this URL to authorize:\n\n{url}\n\nAfter authorization, you'll receive a code. Use it to get access tokens.", ) ]