Welp. RTFM. https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http
async function getDriveItemBySharedLink(sharedLink) {
// First, use base64 encode the URL.
const base64 = Buffer.from(sharedLink).toString("base64");
// Convert the base64 encoded result to unpadded base64url format by removing = characters from the end of the value, replacing / with _ and + with -.)
const converted = base64
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
// Append u! to be beginning of the string.
const updatedLink = `u!${converted}`;
const getDownloadURL = `https://graph.microsoft.com/v1.0/shares/${updatedLink}/driveItem`;
const authResponse = await auth.getToken();
const dirResponse = await axios.get(getDownloadURL, {
headers: {
Authorization: `Bearer ${authResponse.accessToken}`,
},
});
return dirResponse.data;
}