Logo for @tpointurier/ally-microsoft

@tpointurier/ally-microsoft

3rd Party
A Microsoft driver for AdonisJS Ally
Authentication
Created Jul 14, 2024 Updated May 12, 2025

@tpointurier/microsft

Download Version License

@tpointurier/ally-microsoft is a Microsoft driver for AdonisJS Ally.

Getting Started

This package is available in the npm registry.

npm install @tpointurier/ally-microsoft

Next, configure the package by running the followind command.

node ace configure @tpointurier/ally-microsoft

Alternatively, you can use a single command to install and configure the package:

node ace add @tpointurier/ally-microsoft

Then register the service inside the configuration file config/ally.ts.

import { microsoft } from '@tpointurier/ally-microsoft'

const allyConfig: AllyConfig = {
  microsoft: microsoft({
    clientId: env.get('MICROSOFT_CLIENT_ID'),
    clientSecret: env.get('MICROSOFT_CLIENT_SECRET'),
    callbackUrl: env.get('MICROSOFT_CALLBACK_URL'),
    scopes: ['openid', 'profile', 'email'],
    tenantId: env.get('MICROSOFT_TENANT_ID', 'common'),
  }),
}

Available Scopes

Microsoft OAuth2 supports various scopes that you can use to request different levels of access. Here are some commonly used scopes:

  • openid: Required for OpenID Connect authentication
  • profile: Access to basic profile information
  • email: Access to email address
  • offline_access: Get a refresh token
  • User.Read: Read user profile
  • User.Read.All: Read all users' basic profiles
  • Mail.Read: Read user's email
  • Calendars.Read: Read user's calendars
  • Files.Read: Read user's files

You can add these scopes to the configuration like this:

scopes: ['openid', 'profile', 'email', 'User.Read']

For a complete list of available scopes, please refer to the Microsoft Graph permissions reference.