Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

ms_graph_api

120 sites Security covered
View on drupal.org

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
7 months ago
Release cadence
0 days
Stability
0% stable

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