Code Monkey home page Code Monkey logo

sharepoint-rest-upload's Introduction

Uploads a file to sharepoint using the REST API and adal module for the authentication using a certificate.

Be careful the name of the file you want to upload. Sharepoint may not accept special chars.

Set up

$ virtualenv env # Creates a virtualenv in the env folder
$ source env/bin/activate # Load the virtualenv
$ pip3 install -r requirements.txt # Install dependencies
$ python3 rest-upload.py <file path> # Run the script

without virtualenv

$ sudo apt-get install python3-pip
$ pip3 install adal
$ scp -r certificate [email protected]:sharepoint-rest-upload

Generate the certificate

From https://github.com/AzureAD/azure-activedirectory-library-for-python/wiki/Client-credentials

Generate a key:

openssl genrsa -out server.pem 2048

Create a certificate request:

openssl req -new -key server.pem -out server.csr

Generate a certificate:

openssl x509 -req -days 365 -in server.csr -signkey server.pem -out server.crt

You will have to upload this certificate (server.crt) on Azure Portal in your application settings. Once you save this certificate, the portal will give you the thumbprint of this certificate which is needed in the acquire token call. The key will be the server.pem key you generated in the first step.

Create the app

Go to https://portal.azure.com and Azure Active Directory > App Registration. From there create an Wep App / Api application and on the app settings go to Keys and upload the server.crt file. Note the fingerprint.

The Tenant_id can be found from Azure Active Directory > Properties.

Usage

$ python3 rest-upload <file path>

Limitations

This script uses batch upload and has the only limitation of 30 minutes per upload.

sharepoint-rest-upload's People

Contributors

nkcr 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.