Utsav
Here the blue print of app script code to connect with Freshdesk app
Follow documentation for : link
// Replace with your QuickBooks OAuth 2.0 credentials
var CLIENT_ID = 'YOUR_CLIENT_ID';
var CLIENT_SECRET = 'YOUR_CLIENT_SECRET';
var REDIRECT_URI = 'YOUR_REDIRECT_URI';
function getQuickBooksData() {
var oauth2Service = getOAuth2Service();
var token = oauth2Service.getAccessToken();
if (token) {
// You can use the access token to make API requests to QuickBooks
// For example, fetch data from QuickBooks using UrlFetchApp.
var url = 'https://api.quickbooks.com/v3/some_endpoint';
var options = {
headers: {
'Authorization': 'Bearer ' + token
}
};
var response = UrlFetchApp.fetch(url, options);
var data = response.getContentText();
// Process the data as needed.
} else {
Logger.log('Authorization failed');
}
}
function getOAuth2Service() {
return OAuth2.createService('QuickBooks')
.setAuthorizationBaseUrl('https://appcenter.intuit.com/connect/oauth2')
.setTokenUrl('https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer')
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties())
.setScope('openid profile email') // Define required scopes
.setParam('access_type', 'offline');
}
function authCallback(request) {
var oauth2Service = getOAuth2Service();
var authorized = oauth2Service.handleCallback(request);
if (authorized) {
return HtmlService.createHtmlOutput('Authorization successful. You can close this tab.');
} else {
return HtmlService.createHtmlOutput('Authorization failed. Please try again.');
}
}