Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Microsoft Graph API

141 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()}.";

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Sep 2025
Latest release
11 months ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
2.0.0-beta2 Pre-release 9–11 Sep 5, 2025
2.0.0-beta1 Pre-release 9–10 Sep 5, 2025
2.x-dev Dev 9–11 Sep 5, 2025