How to use the @microsoft/microsoft-graph-client.Client.init function in @microsoft/microsoft-graph-client

To help you get started, we’ve selected a few @microsoft/microsoft-graph-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / storages / onedrive / tree.js View on Github external
// 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
        }
github jitsi / jitsi-meet / react / features / calendar-sync / web / microsoftCalendar.js View on Github external
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,
github jitsi / jitsi-meet / react / features / calendar-sync / web / microsoftCalendar.js View on Github external
.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
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 24.bot-authentication-msgraph / simple-graph-client.js View on Github external
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.
            }
        });
    }
github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / storages / onedrive / integration.js View on Github external
utility.assertIsFolder(req.body.autodeskFolder, req, function (autodeskProjectId, autodeskFolderId) {
    //&lt;&lt;&lt;
    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

      // &gt;&gt;&gt;
      utility.prepareAutodeskStorage(autodeskProjectId, autodeskFolderId, fileName, req, function (autodeskStorageUrl, skip, callbackData) {
        if (skip) {
          res.status(409).end(); // no action (server-side)
github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / storages / onedrive / oauth.js View on Github external
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
github microsoft / botframework-solutions / templates / Enterprise-Template / src / typescript / enterprise-bot / src / serviceClients / graphClient.ts View on Github external
private getAuthenticatedClient(): Client {
        return Client.init({
            authProvider: (done: AuthProviderCallback): void => {
                done(undefined, this.token);
            }
        });
    }
}
github microsoft / BotBuilder-Samples / samples / javascript_typescript / 52.enterprise-bot / src / serviceClients / graphClient.ts View on Github external
private getAuthenticatedClient(): Client {
        return Client.init({
            authProvider: (done) => {
                done(null, this._token);
            },
        });
    }
}
github microsoft / botframework-solutions / templates / Virtual-Assistant-Template / typescript / generator-botbuilder-assistant / generators / app / templates / sample-assistant / src / templateManager / graphClient.ts View on Github external
private getAuthenticatedClient(): Client {
        return Client.init({
            authProvider: (done: AuthProviderCallback): void => {
                done(undefined, this.token);
            }
        });
    }
}