🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@microsoft/microsoft-graph-client

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
m

@microsoft/microsoft-graph-client

Microsoft Graph Client Library

3.0.7
latest
99

Supply Chain Security

100

Vulnerability

100

Quality

80

Maintenance

100

License

Network access

Supply chain risk

This module accesses the network.

Found 1 instance in 1 package

Version published
Weekly downloads
377K
-31.61%
Maintainers
3
Weekly downloads
 
Created
Issues
87

What is @microsoft/microsoft-graph-client?

@microsoft/microsoft-graph-client is an npm package that provides a client library for accessing Microsoft Graph, which is a unified API endpoint for accessing data across Microsoft 365 services. This package allows developers to interact with various Microsoft services such as Outlook, OneDrive, and Azure Active Directory, among others.

What are @microsoft/microsoft-graph-client's main functionalities?

Accessing User Information

This feature allows you to access information about the authenticated user. The code sample demonstrates how to initialize the client and make a request to the '/me' endpoint to retrieve user information.

const { Client } = require('@microsoft/microsoft-graph-client');
const client = Client.init({
  authProvider: (done) => {
    done(null, 'YOUR_ACCESS_TOKEN');
  }
});
client.api('/me').get().then((user) => {
  console.log(user);
}).catch((error) => {
  console.error(error);
});

Sending an Email

This feature allows you to send an email using the Microsoft Graph API. The code sample demonstrates how to create an email message and send it using the '/me/sendMail' endpoint.

const { Client } = require('@microsoft/microsoft-graph-client');
const client = Client.init({
  authProvider: (done) => {
    done(null, 'YOUR_ACCESS_TOKEN');
  }
});
const mail = {
  message: {
    subject: 'Hello from Microsoft Graph API',
    body: {
      contentType: 'Text',
      content: 'This is a test email sent using Microsoft Graph API.'
    },
    toRecipients: [
      {
        emailAddress: {
          address: 'recipient@example.com'
        }
      }
    ]
  }
};
client.api('/me/sendMail').post({ message: mail }).then(() => {
  console.log('Email sent successfully');
}).catch((error) => {
  console.error(error);
});

Accessing OneDrive Files

This feature allows you to access files stored in OneDrive. The code sample demonstrates how to list the files in the root directory of the authenticated user's OneDrive using the '/me/drive/root/children' endpoint.

const { Client } = require('@microsoft/microsoft-graph-client');
const client = Client.init({
  authProvider: (done) => {
    done(null, 'YOUR_ACCESS_TOKEN');
  }
});
client.api('/me/drive/root/children').get().then((files) => {
  console.log(files);
}).catch((error) => {
  console.error(error);
});

Other packages similar to @microsoft/microsoft-graph-client

FAQs

Package last updated on 19 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts