Code Monkey home page Code Monkey logo

box-api-access's Introduction

box-api-access

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Use the Box API to manage files in Box Title: Send Logs

Author: Henry Steele - Library Technology Services - Tufts University

Date: February 2019

Requirements:

  • A Box developer's account for your institution
  • Box app in dev console, with public and private key
  • Box admin to approve app
  • a folder you want to write to in Box. Could be a shared folder
  • config (public and private key)
  • see word document for how to set this up

Steps:

1 - Create Box admin user:

Only need to run this script once to set up user.

Edit script:

change the parameters in the commented sections below

  • add a username for the Box Dev app user. This can be the same as the app name from the Box dev console

Command:

  • Before you run this the first time, you can install the requirements by running the following pip command:
    • pip install โ€“r requirements.txt
  • 1st argument to command is the location of the JSON config file from the Box app. You would have downloaded this from the Box dev console within your app
    • python connectToBox-GetLogin.py <config/config.json>

Output:

  • outputs credentials for non-human user that can write and
  • read on behalf of your Box developer app

2-send files

Edit script:

change the parameters in the commented sections below

  • add user ID for non-human Box API user created with connectToBox-GetLogin.py
  • add target folder ID from Box for folder you're writing to

Command:

  • 1st argument to command: file you want to send to Box, with relative path
  • 2nd argument to command: path of config file containing public and private key
  • python sendLogs.py input/input.out config/config.json

Requirements:

  • A Box developer's account for your institution
  • Box app in dev console, with public and private key
  • Box admin to approve app
  • a folder you want to write to in Box. Could be a shared folder
  • config file with public and private key from your app in Box developer cons (public and private key)
  • user ID of the non-human app user created in connectToBox-GetLogin.py
  • target Box folderID, to which the user created in connectToBox-GetLogin.py has been added as an editor or collaborator. Add user by email.
  • Target folder ID is the end of the URL when you are inside that folder in the Box interface

CRON and shell script:

  • I've provided an example of a shell script you can wrap the (second) Python script in, so this can be invoked with a CRON job, although this setup is beyond the scope of this document.

    Output:

    • input file writes to specified Box directory
    • see comments in code below to enter folder ID of this folder
    • see comments in code below to enter folder ID of this folder

box-api-access's People

Contributors

hsteelelts avatar

Stargazers

Andrew Levine avatar Jeremy Hobbs avatar  avatar

Watchers

Mike Korcynski avatar  avatar Bridget Almas avatar James Cloos avatar hughrobinson avatar  avatar  avatar  avatar  avatar Annie DeVane avatar  avatar  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.