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):
- public async initialize() {
- // TODO this grant token will ultimately need to be provided from login page but not sure why required here
- // const grantToken: string = 'xxxxxxxx';
- const logger: Logger = Logger.getInstance(Levels.INFO, `${__dirname}/ts_sdk_log.log`);
- const user: UserSignature = new UserSignature(environment.ZOHO_USER);
- // Using production since that's the one we're in I believe
- const zohoEnv: Environment = USDataCenter.PRODUCTION();
- const token: OAuthToken = new OAuthToken(
- environment.ZOHO_CLIENT_ID,
- environment.ZOHO_CLIENT_SECRET,
- null,
- TokenType.REFRESH,
- environment.ZOHO_REDIRECT_URI
- );
- const tokenStore: TokenStore = this.zohoStore;
- const sdkConfig: SDKConfig = new SDKConfigBuilder().setPickListValidation(false).setAutoRefreshFields(true).build();
- const resourcePath: string = `${__dirname}`;
- // const proxy: RequestProxy = new RequestProxy('localhost', 3005);
- await Initializer.initialize(user, zohoEnv, token, tokenStore, sdkConfig, resourcePath, logger);
- }
- public async authorize() {
- const result = await this.initialize();
- return result;
- }
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