Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Microsoft Graph API

135 sites Security covered
View on drupal.org

This module provides a lightweight wrapper for the Microsoft Graph SDK, making it easier for custom Drupal modules to interact with the Microsoft Graph API. It allows developers to obtain a default API client or instantiate clients with custom keys.

An unofficial, lightweight wrapper around the
Microsoft Graph SDK for PHP,
pulled-in via Composer, for Drupal 8.x.

Use Case

This module is intended to provide an API for other modules to easily obtain
either a site-wide "default" instance of the MS Graph API client using service
injection, or to be able to instantiate an API client using any number of
custom keys.

This module does not provide site builders or end users with any additional
functionality. Install it only if you are developing a custom module or are
using a module that indicates it depends on this module.

Usage

Installation

It is recommended to install this via Composer so that the required version of
the Graph API PHP SDK can be pulled in.

composer require 'drupal/ms_graph_api'

Registration and Configuration

See the README for instructions on how to register your Drupal site with Azure and configure keys.

Obtaining Graph Instances

Afterwards, you can obtain the default, authenticated API graph by getting the
ms_graph_api.graph service and then calling any of the methods on the object
you get back that are
documented for the PHP library.
For example, in procedural code and hooks:

use Microsoft\Graph\Model;

$graph = \Drupal::service('ms_graph_api.graph');

$user =
  $graph
    ->createRequest("GET", "/me")
    ->setReturnType(Model\User::class)
    ->execute();

echo "Hello, I am {$user->getGivenName()}.";

Getting a MS Graph API Graph for a Custom Key

If your site needs to work with multiple Azure subscriptions, you do not need
to configure the default key. Instead, define custom keys (of type
"MS Graph API Key") for each of the different deployments, obtain the Graph
API graph factory service, and construct a different API client for each custom
key.

For example:

use Microsoft\Graph\Model;

$graph_factory = \Drupal::service('ms_graph_api.graph.factory');
$graph = $client_factory->buildGraphFromKeyId('my_graph_api_key');

$user =
  $graph
    ->createRequest("GET", "/me")
    ->setReturnType(Model\User::class)
    ->execute();

echo "Hello, I am {$user->getGivenName()}.";

Activity

Total releases
3
First release
Sep 2025
Latest release
10 months ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Release date
2.0.0-beta2 Pre-release Sep 5, 2025
2.0.0-beta1 Pre-release Sep 5, 2025
2.x-dev Dev Sep 5, 2025