wegene-oauth
Authorize user accounts via WeGene's OAuth2 protocol to obtain access tokens for genetic report analysis and data management.
Instructions
Authorizing a user's account using WeGene Open API with oAuth2 protocol and retrieve a valid access token for further use
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The async handler function `wegene_oauth()` that executes the tool: deletes prior token, prepares OAuth URL, opens browser, polls Redis for new access token up to 120 seconds, returns success or timeout message.async def wegene_oauth(): redis_db.delete('wegene_access_token') # Initialize OAuth2 client client = WebApplicationClient(WEGENE_CLIENT_ID) # Prepare authorization URL authorization_url = client.prepare_request_uri( WEGENE_AUTH_URL, redirect_uri=REDIRECT_URI, scope="basic names athletigen skin psychology risk health" ) webbrowser.open(authorization_url) # Poll for access token for 120 seconds start_time = time.time() while time.time() - start_time < 120: if redis_db.exists('wegene_access_token'): return [ TextContent( type="text", text="User authorization succeeded and access token retrieved. Continue to retrieve user profiles.", ) ] await asyncio.sleep(1) return [ TextContent( type="text", text="Error: User authorization failed in 120 seconds. Please try again." ) ]
- src/wegene_assistant/server.py:139-146 (registration)Registers the 'wegene-oauth' tool in @server.list_tools() with name, description, and empty input schema (no parameters required).types.Tool( name="wegene-oauth", description="Authorizing a user's account using WeGene Open API with oAuth2 protocol and retrieve a valid access token for further use", inputSchema={ "type": "object", "properties": {}, }, ),
- src/wegene_assistant/server.py:225-226 (registration)Dispatches tool calls in @server.call_tool(): invokes the `wegene_oauth()` handler when name is 'wegene-oauth'.if name == "wegene-oauth": return await wegene_oauth()
- src/wegene_assistant/server.py:13-13 (registration)Imports the `wegene_oauth` handler function from oauth_tool.py.from .tools.oauth_tool import wegene_oauth
- Defines the input schema for 'wegene-oauth' tool: empty object (no input parameters).inputSchema={ "type": "object", "properties": {}, },