Connect to Veracross SIS from Google Apps Script
Veracross, Google Apps Script, API, Connect, Utility
This tutorial uses Google Apps Script. If you need to review the Google Apps Script Primer, here it is: Take Me To The Primer
This script simply confirms you have setup your Veracross endpoint/list and you can connect to it.
The first thing you need to do is setup a list inside Veracross that you can access. Here are the instructions for that: https://api-docs.veracross.com/docs/docs/8f8619229c0c4-making-a-data-api-request
If you cannot find this menu, your login is lacking permissions. I had to reach out to their support to get the information to setup the access levels, but then the instructions above worked just fine.
Step 1: Setup a Folder and a Script
As per usual, open Google Drive and make a folder. Inside the folder add a new “Apps Script” file.
When it opens, give it a logical name at the top. And change the code.gs file to “vcconnect”.
Step 2: Get your Client ID and Secret from Veracross
If you followed the steps to setup the list, numbers would have been generated.
The CLIENT SECRET is the longer of the two. Select to edit the script properties.
Paste these into a text file and hold them for the next step.
Step 4: Add the Code
Paste the script below into the Apps Script editor.
function getAccessToken() {
var apiUrl = "https://accounts.veracross.com/vcdemo_client/oauth/token";
// Replace these with your actual client ID and secret
var CLIENT_ID = '';
var CLIENT_SECRET = '';
// Formulate the payload as a URL-encoded query string
var payload = "grant_type=client_credentials" +
"&client_id=" + encodeURIComponent(CLIENT_ID) +
"&client_secret=" + encodeURIComponent(CLIENT_SECRET) +
"&scope=" + encodeURIComponent("students:list");
var options = {
method: "post",
payload: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(apiUrl, options);
var json = JSON.parse(response.getContentText());
Logger.log("Access Token from getAccessToken(): " + json.access_token);
return json.access_token;
}
const APPSEC_ENDPOINT = "https://api.veracross.com/vcdemo_client/v1/applications"; //this is the sandbox url use your own
function testPermissions() {
const accessToken = ""; //getAccessToken();
const options = {
"method": "get",
"headers": {
"Authorization": "Bearer " + accessToken,
},
"muteHttpExceptions": true
};
const response = UrlFetchApp.fetch(APPSEC_ENDPOINT, options);
if (response.getResponseCode() === 200) {
Logger.log("Permissions check successful.");
const json = JSON.parse(response.getContentText());
// If you want to do something with the returned data, you can process the 'json' variable here
Logger.log(json); // For now, let's just log the response.
} else if (response.getResponseCode() === 403) {
// HTTP 403 usually indicates Forbidden (no permission to access the resource)
Logger.log("Permission denied. The provided token does not have access to this endpoint.");
} else {
Logger.log("Error: " + response.getResponseCode() + " | " + response.getContentText());
}
}
Add your API ID and Secret to the script. This is just for testing, in a full implementation, you would store these as script properties.
Run testPermissions() and see if you get a successful connection. Sometimes with Veracross, I have to run this 3 or 4 times intially to get a connection. I have no idea why.
The next script in this process will be released soon, and it will show you how to write this data to Google Sheets.
Copyright © Domain Seven LLC. All rights reserved.
For permissions to use or share any content behind our paywall, please email us at: tonydeprato@domain7.tech .
Any updates on the next script in this process? Additionally, what would be good use cases for this?