Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// driveId:itemId
var idParts = id.split(':')
var driveId = idParts[0]
var id = idParts[1]
var path = ''
try {
if (driveId === '#') {
path = '/me/drives'
} else if (!id) {
path = '/me/drives/' + driveId + '/root/children'
} else {
path = '/me/drives/' + driveId + '/items/' + id + '/children'
}
var msGraphClient = msGraph.init({
defaultVersion: 'v1.0',
debugLogging: true,
authProvider: function (done) {
done(null, credentials.access_token)
}
})
msGraphClient
.api(path)
.get(function (error, data) {
if (error) {
console.log(error)
respondWithError(res, error)
return
}
return (dispatch: Dispatch, getState: Function): Promise<*> => {
const state = getState()['features/calendar-sync'] || {};
const token = state.msAuthState && state.msAuthState.accessToken;
if (!token) {
return Promise.reject('Not authorized, please sign in!');
}
const client = Client.init({
authProvider: done => done(null, token)
});
return client
.api(MS_API_CONFIGURATION.CALENDAR_ENDPOINT)
.get()
.then(response => {
const calendarIds = response.value.map(en => en.id);
const getEventsPromises = calendarIds.map(id =>
requestCalendarEvents(
client, id, fetchStartDays, fetchEndDays));
return Promise.all(getEventsPromises);
})
// get .value of every element from the array of results,
.then(text => {
const client = Client.init({
authProvider: done => done(null, token)
});
return client
.api(`/me/events/${id}`)
.get()
.then(description => {
const body = description.body;
if (description.bodyPreview) {
body.content
= `${description.bodyPreview}<br><br>`;
}
// replace all new lines from the text with html
// <br> to make it pretty
constructor(token) {
if (!token || !token.trim()) {
throw new Error('SimpleGraphClient: Invalid token received.');
}
this._token = token;
// Get an Authenticated Microsoft Graph client using the token issued to the user.
this.graphClient = Client.init({
authProvider: (done) => {
done(null, this._token); // First parameter takes an error if you can't get an access token.
}
});
}
utility.assertIsFolder(req.body.autodeskFolder, req, function (autodeskProjectId, autodeskFolderId) {
//<<<
var storageId = req.body.storageItem;
var idParts = storageId.split(':')
var driveId = idParts[0]
storageId = idParts[1]
var path = '/drives/' + driveId + '/items/' + storageId
var msGraphClient = msGraph.init({
defaultVersion: 'v1.0',
debugLogging: true,
authProvider: function (done) {
done(null, token.getStorageCredentials().access_token)
}
})
msGraphClient
.api(path)
.get(function (err, fileInfo) {
var fileName = fileInfo.name; // name, that's all we need from Google
// >>>
utility.prepareAutodeskStorage(autodeskProjectId, autodeskFolderId, fileName, req, function (autodeskStorageUrl, skip, callbackData) {
if (skip) {
res.status(409).end(); // no action (server-side)
router.get('/api/storage/profile', function (req, res) {
var token = new Credentials(req.session);
var credentials = token.getStorageCredentials();
if (credentials === undefined) {
res.status(401).end();
return;
}
var msGraphClient = msGraph.init({
defaultVersion: 'v1.0',
debugLogging: true,
authProvider: function (done) {
done(null, credentials.access_token)
}
})
msGraphClient
.api('/me')
//.select("displayName")
//.select("mySite")
.get(function (error, data) {
if (error) {
console.log(error)
respondWithError(data, error)
return
private getAuthenticatedClient(): Client {
return Client.init({
authProvider: (done: AuthProviderCallback): void => {
done(undefined, this.token);
}
});
}
}
private getAuthenticatedClient(): Client {
return Client.init({
authProvider: (done) => {
done(null, this._token);
},
});
}
}
private getAuthenticatedClient(): Client {
return Client.init({
authProvider: (done: AuthProviderCallback): void => {
done(undefined, this.token);
}
});
}
}