msgraph

n8n node for Microsoft Graph API with retry handling

Package Information

Released: 8 mo ago
Downloads: 11 weekly / 75 monthly
Latest Version: 0.2.6
Author: advenimuss

Documentation

n8n-nodes-msgraph

This is a custom n8n node that provides enhanced Microsoft Graph API integration with built-in rate limiting and retry handling. It allows you to make requests to any Microsoft Graph API endpoint while automatically handling throttling responses (HTTP 429) using Microsoft's recommended retry-after approach.

Features

  • 🔄 Automatic rate limit handling with retry logic
  • ⏱️ Configurable retry intervals using Microsoft's retry-after header
  • 🎯 Support for all Microsoft Graph API endpoints
  • 🔐 OAuth2 authentication support
  • 📝 Detailed error handling and logging
  • 🛠️ Configurable request parameters (method, URL, headers, query parameters, body)
  • 📦 Response format selection (JSON/String)

Installation

You can install this node in your n8n instance by:

npm install @advenimuss/n8n-nodes-msgraph

Configuration

  1. Create a new Microsoft Graph API credential in n8n:
    • Go to Settings > Credentials > New
    • Search for "Microsoft Graph API"
    • Configure with your Azure AD application details (or with an existing access token via a previous API call to get the token with a client secret)
  2. In your workflow:
    • Add the "Microsoft Graph" node
    • Select your credential
    • Configure the HTTP method, URL, and other parameters
    • Enable/configure rate limit handling if needed

Rate Limiting Features

The node includes smart handling of Microsoft Graph API rate limits:

  • Automatically detects HTTP 429 responses
  • Uses the retry-after header from Microsoft's response
  • Configurable maximum retry attempts
  • Customizable retry delay with expression support
  • Detailed logging of retry attempts

Development Setup

  1. Clone this repository:
git clone https://github.com/advenimuss/n8n-nodes-msgraph.git
cd n8n-nodes-msgraph
  1. Install dependencies:
npm install
  1. Build the node:
npm run build
  1. Link for local testing:
npm link
  1. In your local n8n installation directory:
npm link @advenimuss/n8n-nodes-msgraph

Testing

  1. Run the linter:
npm run lint
  1. Fix linting issues:
npm run lintfix

Building for Production

  1. Update version in package.json
  2. Build the project:
npm run build
  1. Test the build:
npm run lint

Publishing to npm

  1. Login to npm:
npm login
  1. Publish the package:
npm publish --access public

Example Usage

Basic GET Request

{
  "resource": "custom",
  "method": "GET",
  "url": "https://graph.microsoft.com/v1.0/me",
  "authentication": "msGraphOAuth2Api"
}

Handling Rate Limits

{
  "resource": "custom",
  "method": "GET",
  "url": "https://graph.microsoft.com/v1.0/users",
  "authentication": "msGraphOAuth2Api",
  "options": {
    "enableThrottling": true,
    "maxRetries": 5,
    "retryAfter": "{{$response.headers['retry-after'] || 2}}"
  }
}

License

MIT

Support

  • Create an issue in this repository

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Discussion