From 42e578d6cd8db109b6f196b8555ede8b24eaa1ff Mon Sep 17 00:00:00 2001 From: d-klotz Date: Thu, 5 Feb 2026 15:39:56 -0300 Subject: [PATCH 1/4] fix(zoho-crm): remove accountsServer in favor of location-based token URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The accountsServer property was redundant — the location config already provides the correct accounts URL for each datacenter. This simplifies the auth flow by always deriving tokenUri from the location. Co-Authored-By: Claude Opus 4.6 --- packages/v1-ready/zoho-crm/src/api.ts | 25 +++----------------- packages/v1-ready/zoho-crm/src/definition.ts | 7 +----- packages/v1-ready/zoho-crm/src/types.ts | 1 - 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/packages/v1-ready/zoho-crm/src/api.ts b/packages/v1-ready/zoho-crm/src/api.ts index 06ddfd5..07c3919 100644 --- a/packages/v1-ready/zoho-crm/src/api.ts +++ b/packages/v1-ready/zoho-crm/src/api.ts @@ -36,7 +36,7 @@ const LOCATION_CONFIG: Record = in: { accounts: 'https://accounts.zoho.in', api: 'https://www.zohoapis.in' }, au: { accounts: 'https://accounts.zoho.com.au', api: 'https://www.zohoapis.com.au' }, cn: { accounts: 'https://accounts.zoho.com.cn', api: 'https://www.zohoapis.com.cn' }, - ca: { accounts: 'https://accounts.zoho.ca', api: 'https://www.zohoapis.ca' }, + ca: { accounts: 'https://accounts.zohocloud.ca', api: 'https://www.zohoapis.ca' }, jp: { accounts: 'https://accounts.zoho.jp', api: 'https://www.zohoapis.jp' }, sa: { accounts: 'https://accounts.zoho.sa', api: 'https://www.zohoapis.sa' }, }; @@ -46,7 +46,6 @@ const DEFAULT_LOCATION: ZohoLocation = 'us'; export class Api extends OAuth2Requester { public URLs: Record string)>; public location: ZohoLocation; - public accountsServer: string | null; private static readonly CONTACTS_DEFAULT_FIELDS = 'id,First_Name,Last_Name,Email,Phone,Mobile,Account_Name,Company,Owner,Lead_Source,Created_Time,Modified_Time'; private static readonly LEADS_DEFAULT_FIELDS = 'id,First_Name,Last_Name,Email,Phone,Mobile,Company,Industry,Lead_Source,Lead_Status,Owner,Created_Time,Modified_Time,Converted__s,Converted_Date_Time'; @@ -55,7 +54,6 @@ export class Api extends OAuth2Requester { constructor(params: ZohoConfig) { super(params); - this.accountsServer = get(params, 'accountsServer', null) as string | null; this.location = get(params, 'location', DEFAULT_LOCATION) as ZohoLocation; if (!LOCATION_CONFIG[this.location]) { this.location = DEFAULT_LOCATION; @@ -63,9 +61,7 @@ export class Api extends OAuth2Requester { const locationConfig = LOCATION_CONFIG[this.location]; this.baseUrl = `${locationConfig.api}/crm/v8`; - this.tokenUri = this.accountsServer - ? `${this.accountsServer}/oauth/v2/token` - : `${locationConfig.accounts}/oauth/v2/token`; + this.tokenUri = `${locationConfig.accounts}/oauth/v2/token`; this.authorizationUri = encodeURI( `${locationConfig.accounts}/oauth/v2/auth?scope=${this.scope}&client_id=${this.client_id}&redirect_uri=${this.redirect_uri}&response_type=code&access_type=offline` ); @@ -97,10 +93,6 @@ export class Api extends OAuth2Requester { return this.authorizationUri; } - /** - * Sets the datacenter location and updates URLs accordingly. - * Note: tokenUri is only updated if accountsServer is not set. - */ setLocation(location: ZohoLocation): void { if (!LOCATION_CONFIG[location]) { throw new Error( @@ -111,23 +103,12 @@ export class Api extends OAuth2Requester { this.location = location; const locationConfig = LOCATION_CONFIG[location]; this.baseUrl = `${locationConfig.api}/crm/v8`; - if (!this.accountsServer) { - this.tokenUri = `${locationConfig.accounts}/oauth/v2/token`; - } + this.tokenUri = `${locationConfig.accounts}/oauth/v2/token`; this.authorizationUri = encodeURI( `${locationConfig.accounts}/oauth/v2/auth?scope=${this.scope}&client_id=${this.client_id}&redirect_uri=${this.redirect_uri}&response_type=code&access_type=offline` ); } - /** - * Sets the accounts server URL for token operations. - * Call this when accounts-server is provided in OAuth callback. - */ - setAccountsServer(accountsServer: string): void { - this.accountsServer = accountsServer; - this.tokenUri = `${accountsServer}/oauth/v2/token`; - } - async getTokenFromCode(code: string): Promise { const formData = new FormData(); formData.append('grant_type', 'authorization_code'); diff --git a/packages/v1-ready/zoho-crm/src/definition.ts b/packages/v1-ready/zoho-crm/src/definition.ts index 25d1c11..001bf57 100644 --- a/packages/v1-ready/zoho-crm/src/definition.ts +++ b/packages/v1-ready/zoho-crm/src/definition.ts @@ -15,20 +15,16 @@ export const Definition = { getToken: async function(api: Api, params: any): Promise { const code = get(params, 'code'); const location = get(params, 'location', null) as ZohoLocation | null; - const accountsServer = get(params, 'accounts-server', null) as string | null; if (location) { api.setLocation(location); } - if (accountsServer) { - api.setAccountsServer(accountsServer); - } await api.getTokenFromCode(code); }, apiPropertiesToPersist: { credential: ['access_token', 'refresh_token'], - entity: ['location', 'accountsServer'], + entity: ['location'], }, getCredentialDetails: async function (api: Api, userId: string): Promise { const response = await api.listUsers({type: 'CurrentUser'}); @@ -46,7 +42,6 @@ export const Definition = { details: { name: currentUser.email, location: api.location, - accountsServer: api.accountsServer, }, }; }, diff --git a/packages/v1-ready/zoho-crm/src/types.ts b/packages/v1-ready/zoho-crm/src/types.ts index bf5d0a9..ef12d08 100644 --- a/packages/v1-ready/zoho-crm/src/types.ts +++ b/packages/v1-ready/zoho-crm/src/types.ts @@ -12,7 +12,6 @@ export interface ZohoConfig { access_token?: string | null; refresh_token?: string | null; location?: ZohoLocation; - accountsServer?: string | null; } export interface PaginationInfo { From e0c0b5454f8cbab76f0e7cbf55c134de05033e76 Mon Sep 17 00:00:00 2001 From: d-klotz Date: Sat, 7 Feb 2026 06:20:20 -0300 Subject: [PATCH 2/4] feat: add logs --- packages/v1-ready/zoho-crm/src/api.ts | 3 +++ packages/v1-ready/zoho-crm/src/definition.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/v1-ready/zoho-crm/src/api.ts b/packages/v1-ready/zoho-crm/src/api.ts index 07c3919..7a88669 100644 --- a/packages/v1-ready/zoho-crm/src/api.ts +++ b/packages/v1-ready/zoho-crm/src/api.ts @@ -122,7 +122,10 @@ export class Api extends OAuth2Requester { headers: (formData as any).getHeaders(), url: this.tokenUri, }; + console.log("[zoho]: token URL is: ", this.tokenUri); + const response = await this._post(options, false); + console.log("[zoho]: Token response from getTokenFromCode:", JSON.stringify(response)); await this.setTokens(response); return response; } diff --git a/packages/v1-ready/zoho-crm/src/definition.ts b/packages/v1-ready/zoho-crm/src/definition.ts index 001bf57..f052e99 100644 --- a/packages/v1-ready/zoho-crm/src/definition.ts +++ b/packages/v1-ready/zoho-crm/src/definition.ts @@ -15,6 +15,7 @@ export const Definition = { getToken: async function(api: Api, params: any): Promise { const code = get(params, 'code'); const location = get(params, 'location', null) as ZohoLocation | null; + console.log('[zoho]: Received params in getToken:', JSON.stringify(params)); if (location) { api.setLocation(location); From 84d6b10d75534463416770a494fcc2dddaa45759 Mon Sep 17 00:00:00 2001 From: d-klotz Date: Sat, 7 Feb 2026 06:58:03 -0300 Subject: [PATCH 3/4] feat: add logs --- packages/v1-ready/zoho-crm/src/api.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/v1-ready/zoho-crm/src/api.ts b/packages/v1-ready/zoho-crm/src/api.ts index 7a88669..1ab19bc 100644 --- a/packages/v1-ready/zoho-crm/src/api.ts +++ b/packages/v1-ready/zoho-crm/src/api.ts @@ -122,6 +122,9 @@ export class Api extends OAuth2Requester { headers: (formData as any).getHeaders(), url: this.tokenUri, }; + //log client_id and secret + console.log("[zoho]: client_id is: ", this.client_id); + console.log("[zoho]: client_secret is: ", this.client_secret); console.log("[zoho]: token URL is: ", this.tokenUri); const response = await this._post(options, false); From f16314c3724b914ebe7b9c97f98bca8966c333d9 Mon Sep 17 00:00:00 2001 From: d-klotz Date: Sat, 7 Feb 2026 07:50:16 -0300 Subject: [PATCH 4/4] feat: remove added logs --- packages/v1-ready/zoho-crm/src/api.ts | 5 ----- packages/v1-ready/zoho-crm/src/definition.ts | 1 - 2 files changed, 6 deletions(-) diff --git a/packages/v1-ready/zoho-crm/src/api.ts b/packages/v1-ready/zoho-crm/src/api.ts index 1ab19bc..cd05fa0 100644 --- a/packages/v1-ready/zoho-crm/src/api.ts +++ b/packages/v1-ready/zoho-crm/src/api.ts @@ -122,13 +122,8 @@ export class Api extends OAuth2Requester { headers: (formData as any).getHeaders(), url: this.tokenUri, }; - //log client_id and secret - console.log("[zoho]: client_id is: ", this.client_id); - console.log("[zoho]: client_secret is: ", this.client_secret); - console.log("[zoho]: token URL is: ", this.tokenUri); const response = await this._post(options, false); - console.log("[zoho]: Token response from getTokenFromCode:", JSON.stringify(response)); await this.setTokens(response); return response; } diff --git a/packages/v1-ready/zoho-crm/src/definition.ts b/packages/v1-ready/zoho-crm/src/definition.ts index f052e99..001bf57 100644 --- a/packages/v1-ready/zoho-crm/src/definition.ts +++ b/packages/v1-ready/zoho-crm/src/definition.ts @@ -15,7 +15,6 @@ export const Definition = { getToken: async function(api: Api, params: any): Promise { const code = get(params, 'code'); const location = get(params, 'location', null) as ZohoLocation | null; - console.log('[zoho]: Received params in getToken:', JSON.stringify(params)); if (location) { api.setLocation(location);