# azure-graph

> GraphRbacManagementClient Library with typescript type definitions for node

Latest version **4.3.0** (published 2018-11-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install azure-graph
pnpm add azure-graph
yarn add azure-graph
bun add azure-graph
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.3.0 |
| Published | 2018-11-07 |
| First published | 2016-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 950.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1174 |
| Author | Microsoft Corporation |
| Maintainers | windowsazure |
| Keywords | node, azure |

## Links

- npm: https://www.npmjs.com/package/azure-graph
- Repository: https://github.com/azure/azure-sdk-for-node
- Homepage: https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/graphManagement
- Issues: https://github.com/azure/azure-sdk-for-node/issues
- npm.io page: https://npm.io/package/azure-graph

## Dependencies (2)

- [ms-rest](https://npm.io/package/ms-rest.md) ^2.3.3
- [ms-rest-azure](https://npm.io/package/ms-rest-azure.md) ^2.5.5

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 4.3.0 (latest) — 2018-11-07
- 4.2.0 — 2018-10-29
- 4.1.0 — 2018-10-12
- 4.0.0 — 2018-10-11
- 3.1.0 — 2018-08-27
- 3.0.0 — 2018-06-14
- 2.2.0 — 2017-09-23
- 2.1.0-preview — 2017-05-15
- 2.0.0-preview — 2017-04-03
- 1.1.1 — 2016-09-22
- 1.1.0 — 2016-09-02
- 1.0.1 — 2016-06-21
- 1.0.0 — 2016-06-17
- 0.1.1 — 2016-03-04
- 0.1.0 — 2016-03-03

## README

# Microsoft Azure SDK for Node.js - Graph Management

This project provides a Node.js package that makes it easy to manage MicrosoftGraph Resources. Right now it supports:
- **Node.js version: 6.x.x or higher**

## How to Install

```bash
npm install azure-graph
```

## How to use

### Authentication, client creation and listing users as an example

##### Interactive Login
 ```javascript
 var msRestAzure = require('ms-rest-azure');
 var graphRbacManagementClient = require('azure-graph');

 // It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, 
 // the user will get a DeviceTokenCredentials object.

 //Note: You need to explicitly specify the tokenAudience as graph and the your domain (tenantId) in which the AD Graph exists. 
 //      This needs to be done only for working graph clients. For other ARM clients specifying this information is not required.
 var tenantId='abcd-efgh-ijk-lmno-12345';
 // Enter your tenant ID here which can be found from your Azure AD URL
 // Eg. https://manage.windowsazure.com/example.com#Workspaces/ActiveDirectoryExtension/Directory/<TenantId>/users
 
 msRestAzure.interactiveLogin({ tokenAudience: 'graph', domain: tenantId }, function (err, credentials, subscriptions) {
  if (err) console.log(err);
  var client = new graphRbacManagementClient(credentials, tenantId);
  var userParams = {
    accountEnabled: true,
    userPrincipalName: 'OfficialStark@<yourdomain.com>', //please add your domain over here
    displayName: 'Jon Snow',
    mailNickname: 'OfficialStark',
    passwordProfile: {
      password: 'WinterisComing!',
      forceChangePasswordNextLogin: false
    }
  };
  client.users.create(userParams, function (err, user, request, response) {
    if (err) return console.log(err);
    console.log(user);
    var userObjectId = user.objectId;
    client.users.list(function (err, result, request, response) {
      if (err) return console.log(err);
      console.log(result);
      client.users.deleteMethod(userObjectId, function (err, result, request, response) {
        if (err) return console.log(err);
        console.log(result);
      });
    });
  });
 });
```

##### Login with username and password (organizational accounts)
```javascript
 var msRestAzure = require('ms-rest-azure');
 var graphRbacManagementClient = require('azure-graph');
 var tenantId='abcd-efgh-ijk-lmno-12345';
 // Enter your tenant ID here which can be found from your Azure AD URL
 // Eg. https://manage.windowsazure.com/example.com#Workspaces/ActiveDirectoryExtension/Directory/<TenantId>/users
 
 msRestAzure.loginWithUsernamePassword('username@contosocorp.onmicrosoft.com', 'your-password', { tokenAudience: 'graph', domain: tenantId }, function (err, credentials, subscriptions) {
  if (err) console.log(err);
  var client = new graphRbacManagementClient(credentials, tenantId);
  var userParams = {
    accountEnabled: true,
    userPrincipalName: 'OfficialStark@<yourdomain.com>', //please add your domain over here
    displayName: 'Jon Snow',
    mailNickname: 'OfficialStark',
    passwordProfile: {
      password: 'WinterisComing!',
      forceChangePasswordNextLogin: false
    }
  };
  client.users.create(userParams, function (err, user, request, response) {
    if (err) return console.log(err);
    console.log(user);
    var userObjectId = user.objectId;
    client.users.list(function (err, result, request, response) {
      if (err) return console.log(err);
      console.log(result);
      client.users.deleteMethod(userObjectId, function (err, result, request, response) {
        if (err) return console.log(err);
        console.log(result);
      });
    });
  });
 });
```

##### Login with serviceprincipal and secret
```javascript
 var msRestAzure = require('ms-rest-azure');
 var graphRbacManagementClient = require('azure-graph');
 var tenantId='abcd-efgh-ijk-lmno-12345';
 // Enter your tenant ID here which can be found from your Azure AD URL
 // Eg. https://manage.windowsazure.com/example.com#Workspaces/ActiveDirectoryExtension/Directory/<TenantId>/users
 
 msRestAzure.loginWithServicePrincipalSecret('clientId', 'application-secret', tenantId, { tokenAudience: 'graph' }, function (err, credentials, subscriptions) {
  if (err) console.log(err);
  var client = new graphRbacManagementClient(credentials, tenantId);
  var userParams = {
    accountEnabled: true,
    userPrincipalName: 'OfficialStark@<yourdomain.com>', //please add your domain over here
    displayName: 'Jon Snow',
    mailNickname: 'OfficialStark',
    passwordProfile: {
      password: 'WinterisComing!',
      forceChangePasswordNextLogin: false
    }
  };
  client.users.create(userParams, function (err, user, request, response) {
    if (err) return console.log(err);
    console.log(user);
    var userObjectId = user.objectId;
    client.users.list(function (err, result, request, response) {
      if (err) return console.log(err);
      console.log(result);
      client.users.deleteMethod(userObjectId, function (err, result, request, response) {
        if (err) return console.log(err);
        console.log(result);
      });
    });
  });
 });
 ```

- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node)

---
_Source: https://npm.io/package/azure-graph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
