Skip to content

Instantly share code, notes, and snippets.

View allenmichael's full-sized avatar

Allen-Michael Grobelny allenmichael

  • Amazon Web Services
  • Austin, TX
  • X @amsxbg
View GitHub Profile
'use strict';
const box = require('box-node-sdk');
const fs = require('fs');
let configFile = fs.readFileSync('config.json');
configFile = JSON.parse(configFile);
let session = box.getPreconfiguredInstance(configFile);
let serviceAccountClient = session.getAppAuthClient('enterprise');
serviceAccountClient.enterprise.addAppUser("externalID", { "external_app_user_id": "auth0ID" })
@allenmichael
allenmichael / Program.cs
Last active September 18, 2017 21:44
Authenticate and get Service Account user info
using System;
using System.IO;
using System.Threading.Tasks;
using Box.V2;
using Box.V2.Config;
using Box.V2.JWTAuth;
namespace BoxPlayground
{
public class Program
@allenmichael
allenmichael / main.java
Last active September 18, 2017 21:43
Authenticate and log out Service Account information
package com.boxplayground;
import com.box.sdk.*;
import java.io.FileReader;
import java.io.Reader;
public class App {
public static void main( String[] args ) {
// Open a reader to read and dispose of the automatically created Box configuration file.
try(Reader reader = new FileReader("src/config/config.json")) {
// Initialize the SDK with the Box configuration file and create a client that uses the Service Account.
@allenmichael
allenmichael / app.js
Last active September 18, 2017 21:53
Authenticate Box Service Account and list the Service Account's info.
'use strict';
// Require the Box SDK and the fs module
const box = require('box-node-sdk');
const fs = require('fs');
// Read and parse the automatically created Box configuration file.
let configFile = fs.readFileSync('config.json');
configFile = JSON.parse(configFile);
// Initialize the SDK with the Box configuration file and create a client that uses the Service Account.
@allenmichael
allenmichael / app.js
Created September 15, 2017 09:40
Authenticate to Box with a Service Account and create a new App User
'use strict';
let BoxService = require('./boxClientService');
let Box = require('box-node-sdk');
const fs = require('fs');
let configFile = fs.readFileSync('config.json');
configFile = JSON.parse(configFile);
let BoxInstance = Box.getPreconfiguredInstance(configFile);
let serviceAccount = BoxInstance.getAppAuthClient('enterprise');
serviceAccount.enterprise.addAppUser('test appuser', null, function (err, user) {
if (err) {
package com.amsxbg;
import com.box.sdk.*;
import java.io.FileReader;
import java.io.Reader;
public class App {
public static void main( String[] args ) {
try(Reader reader = new FileReader("src/config/config.json")) {
BoxConfig boxConfig = BoxConfig.readFrom(reader);
BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig);
# Change this file path
$FILE_PATH = "C:\Users\AM\Documents\Welcome.pptx"
$USER_ID = box users create otis --app-user --id-only;
$FOLDER_ID = box folders create 0 first-folder --as-user $USER_ID --id-only;
box files upload $FILE_PATH --as-user $USER_ID -p $FOLDER_ID;
@allenmichael
allenmichael / GeneralUtilities.cs
Created June 30, 2017 19:19
Fixed GeneralUtilities for Win environment
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace BoxCLI.CommandUtilities
{
public static class GeneralUtilities
{
@allenmichael
allenmichael / BoxService.cs
Last active February 19, 2019 07:48
Example for multiput upload in a simple Console Application
using System;
using System.IO;
using Box.V2;
using Box.V2.Config;
using Box.V2.JWTAuth;
namespace BoxPlayground
{
public static class BoxService
{
@allenmichael
allenmichael / document-lists.json
Created January 21, 2016 19:54
JSON for document lists in Mozu
{
"startIndex": 0,
"pageSize": 10,
"pageCount": 1,
"totalCount": 8,
"items": [
{
"name": "files",
"namespace": "mozu",
"listFQN": "files@mozu",