<commit_before># graph-service

A service for accessing the Microsoft Graph API.

Version 2.0.2

Exports the `GraphService` class allowing you to access the Microsoft Graph API at `https://graph.microsoft.com`. The `GraphService` class is subclassed from the [`HttpsService`](https://github.com/fhellwig/https-service) class. The `GraphService` class constructor requires a credentials object having a `getAccessToken` method to obtain the bearer token that is sent with each request. You can use the [`ClientCredentials`](https://github.com/fhellwig/client-credentials) or provide your own instance as long as it provides the `getAccessToken` method that returns a promise resolved with an access token.

## 1. Installation

```bash
$ npm install --save graph-service
```

## 2. Usage

```javascript
const GraphService = require('graph-service');

const api = new GraphService('my-company.com', 'client-id', 'client-secret');

api.all('/v1.0/users').then(response => {
    console.log(response.data);
});
```

### 2.1 Endpoints

By default, this utility uses the `https://graph.microsoft.com` endpoint. You can specify the older `https://graph.windows.net` endpoint by adding a version number as the last argument in the constructor:

```javascript
const api = new GraphService('my-company.com', 'client-id', 'client-secret', '<PASSWORD>');
```

This will use the older endpoint and add the `api-version` query parameter to all paths.

## 3. API

Since the `GraphService` class subclasses the [HttpsService](https://github.com/fhellwig/https-service) class, the API is identical as for that class, with three exceptions. First, the constructor accepts the same arguments as the [ClientCredentials](https://github.com/fhellwig/client-credentials) class. Second, there is an additional `authorizedRequest` method that accepts a token provided by the client instead of using the client credentials created in the constructor. Third, the `all` method performs repeated `GET` requests, accumulating the results.

### 3.1 constructor

```javascript
GraphService([tenant, clientId, clientSecret])
```

Creates a new `GraphService` instance for the specified `tenant`. The `clientId` and the `clientSecret` must be for an AAD application that has access rights to the Microsoft Graph resource (`https://graph.microsoft.com`). These three parameters are optional. If you have your own token, and wish to only call the `me` API resources, then you can call the constructor with no arguments. In that case, you must use the `authorizedRequest` method instead of the `request` method, passing in your own access token as the first parameter.
<commit_msg>In progress updates for new version.<commit_after># graph-service

A service for accessing the Microsoft Graph API.

Version 2.0.2

Exports the `GraphService` class allowing you to access the Microsoft Graph API at `https://graph.microsoft.com`. The `GraphService` class is subclassed from the [`HttpsService`](https://github.com/fhellwig/https-service) class. The `GraphService` class constructor requires a credentials object having a `getAccessToken` method to obtain the bearer token that is sent with each request. You can use the [`ClientCredentials`](https://github.com/fhellwig/client-credentials) or provide your own instance as long as it provides the `getAccessToken` method that returns a promise resolved with an access token.

The default Graph API version is `v1.0`. This can be overridded in the constructor (e.g., `beta`).

## 1. Installation

Install this package and, optionally, the [`client-credentials`](https://github.com/fhellwig/client-credentials) package.
```bash
$ npm install --save graph-service
$ npm install --save client-credentials
```

## 2. Usage

```javascript
const GraphService = require('graph-service');
const ClientCredentials = require('client-credentials');

const clientId = '0b13aa29-ca6b-42e8-a083-89e5bccdf141';
const clientSecret = 'lsl2isRe99Flsj32elwe89234ljhasd8239jsad2sl='
const credentials = new ClientCredentials('my-company.com', '<client-id', '<client-secret>');
const service = new GraphService(credentials)

service.all('/users').then(response => {
    console.log(response.data);
});
```

### 2.1 Endpoints

By default, this utility uses the `https://graph.microsoft.com` endpoint. You can specify the older `https://graph.windows.net` endpoint by adding a version number as the last argument in the constructor:

```javascript
const api = new GraphService('my-company.com', 'client-id', 'client-secret', '<PASSWORD>');
```

This will use the older endpoint and add the `api-version` query parameter to all paths.

## 3. API

Since the `GraphService` class subclasses the [HttpsService](https://github.com/fhellwig/https-service) class, the API is identical as for that class, with three exceptions. First, the constructor accepts the same arguments as the [ClientCredentials](https://github.com/fhellwig/client-credentials) class. Second, there is an additional `authorizedRequest` method that accepts a token provided by the client instead of using the client credentials created in the constructor. Third, the `all` method performs repeated `GET` requests, accumulating the results.

### 3.1 constructor

```javascript
GraphService([tenant, clientId, clientSecret])
```

Creates a new `GraphService` instance for the specified `tenant`. The `clientId` and the `clientSecret` must be for an AAD application that has access rights to the Microsoft Graph resource (`https://graph.microsoft.com`). These three parameters are optional. If you have your own token, and wish to only call the `me` API resources, then you can call the constructor with no arguments. In that case, you must use the `authorizedRequest` method instead of the `request` method, passing in your own access token as the first parameter.

{'fraction_non_alphanumeric': 0.10063650438671942, 'fraction_numerical': 0.009805608119731636, 'mean_word_length': 5.139387539598733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 17, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3762771', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1506, 'n_words': 676}