Giter Site home page Giter Site logo

netdocs's Introduction

A Python wrapper for the NetDocuments API.

Install and configuration

Requirements:

  • Python 3+
  • Requests
  • Flask (for web server to retrieve the access token)

Install via pip:

pip install netdocs

Setup Client Data

To access the API you'll need to register an app via the Net Documents Developer Portal.

This will then give you a client id and secret. You will also need to register a redirect URI - set this as https://localhost:3000/gettoken.

Next create a file called ".netdocs". It's recommended to place this in your home directory (i.e. at "~/").

[Client Parameters]
c_id = [Paste your client id here]
c_secret = [Paste your client secret here]
scope = read [select from 'read', 'edit', 'organize', 'lookup', 'delete_doc', 'delete_container', 'full']
access_token = [Leave blank - will be retrieved]
refresh_token = [Leave blank - will be retrieved]

[URLs]
auth_url = https://vault.netvoyage.com/neWeb2/OAuth.aspx
redirect_uri = https://localhost:3000/gettoken [Register this in your App configuration - you can use a different uri if required]
refresh_url = https://api.vault.netvoyage.com/v1/OAuth
base_url = https://api.vault.netvoyage.com

If you use a service other than 'vault' (e.g. 'EU') change the urls accordingly.

Getting an Access Token

The package provides a small webserver to enable you to connect to the Net Documents service and authorise the app.

Net Documents requires an SSL (https) connection. To provide this generate a self-signed certificate and key. Make sure you have openssl installed then run from the terminal:

openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout domain.key -out domain.crt

The webserver will look for the "domain.crt" and "domain.key" files in your home directory.

Running the Webserver

To run the webserver and get an access token run the following after installing the package:

python -m netdocs.webserver

Then point your browser at https://localhost:3000/ndsetup.

You will probably get a warning about the self-signed certificate - click the advanced options and "Connect Anyway" option.

You will then be redirected to login to Net Documents and authorise the app with the scope set in 'Client Parameters' above.

After authorising the app you will be redirected to the webserver again. If all is successful this will be indicated with a message in the browser.

Use

Once the steps above have been completed you can then use the Python NetDocs class.

Start by importing this class:

from netdocs import NetDocs
nd = NetDocs()

Example methods so far are:

# Get information on current user
info = nd.get_user_data()
# Get information on available cabinets
cabinets = nd.get_cabinents()
# Get information on a document with id [docid]
docinfo = nd.get_doc_info(docid)
# Get information on a folder with id [folderid]
folderinfo = nd.get_folder_info(folderid)
# Get contents of a folder with id [folderid]
foldercontents = folder_content(folderid)

netdocs's People

Contributors

benhoyle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.