This commit is contained in:
2024-08-19 20:22:59 +05:00
parent f05047910b
commit b67d789e88
19 changed files with 628 additions and 58 deletions
+33
View File
@@ -0,0 +1,33 @@
import got from "got";
interface IResult {
access_token: string;
scope: string;
api_domain: string;
token_type: string;
expires_in: number;
}
async function getAccessToken() {
try {
const refreshToken =
"1000.3fe84b5d46a29eda6ea809f87f9bd763.41ed80716ca3cc53c149d0c2c238456b";
const grantType = "refresh_token";
const clientId = "1000.AXAHCN0E0GKQMDP4K8LM0XJ5KQQMCL";
const clientSecret = "59f54273e498401489bbf211e63c14a7c747a26afe";
const result: IResult = await got
.post(
`https://accounts.zoho.com/oauth/v2/token?refresh_token=${refreshToken}&grant_type=${grantType}&client_id=${clientId}&client_secret=${clientSecret}`
)
.json();
console.log("result", result);
return { accessToken: result.access_token };
} catch (error) {
return { error: (error as Error).message };
}
}
export default getAccessToken;