auth_get_url
Generate OAuth authorization URL to authenticate and connect with FreshBooks for accounting, invoicing, time tracking, and expense management.
Instructions
Get OAuth authorization URL to authenticate with FreshBooks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:197-222 (handler)The handler function for executing the auth_get_url tool. Generates the OAuth authorization URL and returns it along with instructions for the user.* Handle auth_get_url tool */ private async handleAuthGetUrl() { const url = this.oauth.generateAuthorizationUrl(); return { content: [ { type: 'text', text: JSON.stringify( { authorizationUrl: url, instructions: [ '1. Visit the authorization URL in your browser', '2. Log in to FreshBooks and authorize the application', '3. Copy the authorization code from the redirect URL', '4. Call auth_exchange_code with the authorization code', ], }, null, 2 ), }, ], }; }
- src/server.ts:91-97 (registration)Registration of the auth_get_url tool in the MCP listTools handler, defining its name, description, and empty input schema.name: 'auth_get_url', description: 'Get OAuth authorization URL to authenticate with FreshBooks', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:93-96 (schema)Input schema for the auth_get_url tool (no parameters required).inputSchema: { type: 'object', properties: {}, },
- src/auth/oauth.ts:65-83 (helper)Core helper function that constructs the OAuth authorization URL using FreshBooks endpoints, client credentials, and optional state.generateAuthorizationUrl(state?: string): string { const params = new URLSearchParams({ client_id: this.config.clientId, response_type: 'code', redirect_uri: this.config.redirectUri, }); // Add scopes if configured if (this.config.scopes?.length) { params.set('scope', this.config.scopes.join(' ')); } // Add state parameter for CSRF protection if (state) { params.set('state', state); } return `${FreshBooksOAuth.AUTH_URL}?${params.toString()}`; }