npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-waad

v2.5.0

Published

query windows azure active directory

Downloads

52

Readme

Query Windows Azure Active Directory graph

npm install node-waad

General usage

UPDATE: we updated the package to use the api-version 1.0. We implemented a couple of methods only. The version 0.5 has more things implemented (like paging).

Get an access token and query the graph

Alternatively you can call waad.getGraphClient in one function

var waad = require('node-waad');

waad.getGraphClient10('auth10dev.onmicrosoft.com', 'client-id', 'client-secret', function(err, client) {
  // query the graph
  client.getUserByMail('[email protected]', function(err, user) {
    // get user properties (user.displayName, user.mail, etc.)
  });
});

Graph methods (API v1.0)

getUsers([options], callback)

Fetch a list of all users.

Callback is a function with two arguments err and users. Users is an array of user objects (paging not implemented, use v0.5)

getUserByEmail(email, callback)

Fetch one user by its email address. Parameters:

  • email the email address of the requested user.
  • callback is a function with two arguments err and user. It will always return 1 user or null.

getUserByProperty(accessToken, tenant, propertyName, propertyValue, [options], callback)

Fetch one user by the specified property. Parameters:

  • accessToken a valid access token that you can obtain with the two afore mentioned methods.
  • tenant the id of the tenant.
  • propertyName the name of the property.
  • propertyValue the value of the property (match is exact).
  • options optional. Two properties supported. includeGroups set to true returns only the groups that the user is a direct member of. When also setting includeNestedGroups to true includes all the groups in the user.groups property. Warning when includeGroups is true an additional request will be made for every user. When includeNestedGroups is true an additional request will be made for every user.
  • callback is a function with two arguments err and user. It will always return 1 user or null.

getGroupsForUserByObjectIdOrUpn(objectIdOrUpn, callback)

Fetch the list of groups the user belongs to. Parameters:

  • objectIdOrUpn the objectId or userPrincipalName of the user.
  • callback is a function with two arguments err and groups.

How to Get a client ID and client secret

Read this tutorial from Microsoft Adding, Updating, and Removing an App

API version 0.5

Get an access token and query the graph

Alternatively you can call waad.getGraphClient in one function

var waad = require('node-waad');

waad.getGraphClient('auth10dev.onmicrosoft.com', 'spn-appprincipal', 'symmetric-key-base64', function(err, client) {
  // query the graph
  client.getUserByEmail('[email protected]', function(err, user) {
    // get user properties (user.DisplayName, user.Mail, etc.)
  });
});

Or use ```getGraphClientWithClientCredentials```:

```js
var waad = require('node-waad');

waad.getGraphClientWithClientCredentials('auth10dev.onmicrosoft.com', 'myapp.com', 'client-id', 'client-secret', function(err, client) {
  // query the graph
  client.getUserByEmail('[email protected]', function(err, user) {
    // get user properties (user.DisplayName, user.Mail, etc.)
  });
});

Graph methods (API v0.5)

getUsers([options], callback)

Fetch a list of all users.

Callback is a function with two arguments err and users. Users is an array of user objects with few additional properties:

  • hasMorePages true if there are more users for this query
  • skiptoken if there is more pages for this query, you will have to use this skiptoken to get the next page.
  • nextPage(callback) if you want to fetch the next page inmediately, you can use this method instead of the afore mentioned skiptoken. The callback for this method works in the same way than the getUsers callback.

Options has the following optional properties:

  • options optional. Two properties supported. includeGroups set to true returns only the groups that the user is a direct member of in the user.groups property. Warning when includeGroups is true an additional request will be made for every user.
  • skiptoken optional when set will fetch the next page of the result set.
  • top the maximum amount of users we want for this query.

getUserByEmail(email, [options], callback)

Fetch one user by its email address. Parameters:

  • email the email address of the requested user.
  • options optional. Two properties supported. includeGroups set to true returns only the groups that the user is a direct member of in the user.groups property. Warning when includeGroups is true an additional request will be made for every user.
  • callback is a function with two arguments err and user. It will always return 1 user or null.

getUserByProperty(accessToken, tenant, propertyName, propertyValue, [options], callback)

Fetch one user by the specified property. Parameters:

  • accessToken a valid access token that you can obtain with the two afore mentioned methods.
  • tenant the id of the tenant.
  • propertyName the name of the property.
  • propertyValue the value of the property (match is exact).
  • options optional. Two properties supported. includeGroups set to true returns only the groups that the user is a direct member of in the user.groups property. Warning when includeGroups is true an additional request will be made for every user.
  • callback is a function with two arguments err and user. It will always return 1 user or null.

getGroupsForUserByEmail(email, callback)

Fetch the list of groups the user belongs to. Parameters:

  • email the email address of the requested user.
  • callback is a function with two arguments err and groups.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.