How to create Zoho API OAuth Token?

How to create Zoho API OAuth Token?

I'm building integration with your API using your Typescript library, but I don't understand your documentation to successfully create an OAuth token.

Typically, my client would get called (/authorize endpoint) which should call your endpoint to prompt the user to put in their Zoho credentials, then you would call my callback (/authorize/callback endpoint). However, I don't see how to initiate this flow. I assume you would be using Authorization Code Flow for that. Is that correct?

I have created a server client on the developer portal as follows and placed all the keys in my config file for use in my API call:



Then per your docs, I create a means to call the initializer from my initial /authorize endpoint, as follows (I also tried creating a self-client and pass in a Grant token manually per line 4):

  1.   public async initialize() {
  2.     // TODO this grant token will ultimately need to be provided from login page but not sure why required here
  3.     // const grantToken: string = 'xxxxxxxx';
  4.     const logger: Logger = Logger.getInstance(Levels.INFO, `${__dirname}/ts_sdk_log.log`);
  5.     const user: UserSignature = new UserSignature(environment.ZOHO_USER);
  6.     // Using production since that's the one we're in I believe
  7.     const zohoEnv: Environment = USDataCenter.PRODUCTION();
  8.     const token: OAuthToken = new OAuthToken(
  9.       environment.ZOHO_CLIENT_ID,
  10.       environment.ZOHO_CLIENT_SECRET,
  11.       null,
  12.       TokenType.REFRESH,
  13.       environment.ZOHO_REDIRECT_URI
  14.     );

  15.     const tokenStore: TokenStore = this.zohoStore;
  16.     const sdkConfig: SDKConfig = new SDKConfigBuilder().setPickListValidation(false).setAutoRefreshFields(true).build();
  17.     const resourcePath: string = `${__dirname}`;
  18.     // const proxy: RequestProxy = new RequestProxy('localhost', 3005);

  19.     await Initializer.initialize(user, zohoEnv, token, tokenStore, sdkConfig, resourcePath, logger);
  20.   }

  21.   public async authorize() {
  22.     const result = await this.initialize();
  23.     return result;
  24.   }



After this, I would expect it to allow me to enter my credentials to create an OAuth token and after I successfully login, it would call my callback so that I can save the resulting OAuth token.

Can you please describe how I can achieve this? Ideally I would like our end users to log in using their credentials so we can access their tenet

Thanks,
Lou