Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktonon/o365-sharepoint-api-demo
This is a short node script that demonstrates authentication with an Active Directory app configured with access to SharePoint
https://github.com/ktonon/o365-sharepoint-api-demo
Last synced: about 1 month ago
JSON representation
This is a short node script that demonstrates authentication with an Active Directory app configured with access to SharePoint
- Host: GitHub
- URL: https://github.com/ktonon/o365-sharepoint-api-demo
- Owner: ktonon
- Created: 2014-11-11T19:10:39.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-11T19:51:49.000Z (about 10 years ago)
- Last Synced: 2023-03-23T23:53:15.323Z (almost 2 years ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Office 365 SharePoint API Demo
==============================This is a short node script that demonstrates authentication with an Active Directory app configured with access to SharePoint. This script only works if read access to SharePoint files is configured on the app.
Instructions
------------* Clone this repo
* Copy `lib/config.example.json` to `lib/config.json` and fill in the values (see next section)
* Run `npm install`
* Run `node lib/index.json`
* A browser will open. Authenticate and give the script access. After authenticating the script will:
* Get an access token
* Use the auth token to get the sharepoint api endpoint from the discovery service
* Get a new access token given a refresh token
* Use the new access token to get a list of files from sharepoint. The previously found endpoint is usedRunning the script as
```
node lib/index.json
```will use the preview discovery api. Running the script as
```
node lib/index.json 1.0
```will use the 1.0 version of the discovery api.
config.json
-----------* `clientId` - Active Directory app client id. Get this in the [Azure Management Portal][] on the Active Directory app's Configure page.
* `clientSecret` - Active Directory app secret key. Get this in the [Azure Management Portal][] on the Active Directory app's Configure page. You can only see the key immediately after creating it. If you forgot your key, create a new one.
* `port` - Port to use when running a local server. The local server responds to the redirect after authentication takes place. Your Active Directory app must have a reply url configured for this port. For example, if your port is 8000, then a single sign-on reply url must be `http://localhost:8000`. Set this value on the Active Directory app's Configure page.
* `sharepointHost` - sharepoint host name. To figure out this value, login to [Office 365][], and then navigate to OneDrive. Should look something like `some-subdomain.sharepoint.com`Issues
------Currently only the endpoint returned from the preview discovery service actually works. If the 1.0 discovery service is used, the sharepoint endpoint complains with this error:
```json
{
"error": {
"code": "-2147024891, System.UnauthorizedAccessException",
"message": "Access denied. You do not have permission to perform this action or access this resource."
}
}
```[Azure Management Portal]:https://manage.windowsazure.com
[Office 365]:https://outlook.office365.com