Box integration

Looking at the dropbox example to see how to add box integration... anybody else interested in this?

Comments

  • box.net, Google Drive, and SkyDrive all seem like viable solutions for this. I'd love to see connectors for them all.
  • This is a client test for Box Integration:
     enyo.kind({
    name: "App",
    components: [

    {kind: "Button", content: "Authorize", ontap: "authAction"},

    {name: "listInput", kind: "Input", value: "public"},

    {name: "listButton", kind: "Button", content: "Go to Box - After you come back tap 'Get Token'", ontap: "listAction", disabled: true},

    {name: "TokenButton", kind: "Button", content: "Get Token", ontap: "tokenAction", disabled: true},
    {name: "See", kind: "Button", content: "See Info", ontap: "seeAction", disabled: true},
    {name: "output", allowHtml: true}

    ],

    create: function() {

    this.inherited(arguments);

    this.apikey = <your api key>; //obtain from Box Platform Developers Page
    },

    authAction: function() {

    this.$.output.addContent("Requesting tokens...<br/>");

    var request = new enyo.Ajax({
    url: "https://www.box.com/api/1.0/rest?action=get_ticket&api_key=&quot; + this.apikey,
    handleAs: "xml"
    })
    ;
    request.response(this, function(inSender, inGoodies) {
    console.log(inGoodies);

    xmlDoc = inGoodies.childNodes[0].childNodes[1].textContent;
    console.log(xmlDoc);
    if (xmlDoc) {
    this.auth_token = xmlDoc;
    console.log

    (this.auth_token); //this.auth_secret = inGoodies.secret;


    //this.$.output.addContent(xmlDoc);
    this.$.listButton.setDisabled(false);


    } else {
    this.$.output.addContent("failed" + inGoodies);


    }
    })
    ;
    request.go(/*{user: "user", password: "password"}*/)
    ;

    },

    listAction: function() {

    this.$.output.addContent("Requesting list...[" + this.$.listInput.getValue() + "]<br/>");

    this.$.TokenButton.setDisabled(false);

    window.open("https://www.box.com/api/1.0/auth/&quot; + this.auth_token)
    ;
    /*.go({token: this.auth_token, secret: this.auth_secret})

    .response(this, function(inSender, inGoodies) {
    this.$.output.addContent

    (enyo.json.stringify(inGoodies) + "<hr/>");
    })
    ;

    */ },
    tokenAction: function() {

    //https://www.box.com/api/1.0/rest?action=get_auth_token&api_key={your api key}&ticket={your ticket}
    new enyo.Ajax({ url: "https://www.box.com/api/1.0/rest?action=get_auth_token&api_key=&quot; +

    this.apikey + "&ticket="+ this.auth_token, handleAs: "xml"})

    .go(/*{token: this.auth_token, secret: this.auth_secret}*/)

    .response(this, function(inSender, inGoodies) {
    console.log(inGoodies);

    xmlDoc = inGoodies.childNodes[0].childNodes[1].textContent;
    console.log(xmlDoc);
    if (xmlDoc) {

    this.auth_token = xmlDoc;

    console.log(this.auth_token);
    new enyo.Ajax({ url: "https://www.box.com/api/2.0/folders/0", headers: {"Authorization": "BoxAuth api_key=" +

    this.apikey + "&auth_token="+ this.auth_token}, handleAs: "json"})

    .go(/*{token: this.auth_token, secret: this.auth_secret}*/)

    .response(this, function(inSender, inGoodies) {


    this.$.output.addContent(enyo.json.stringify(inGoodies) + "<br/>");

    });
    this.$.See.setDisabled(false);
    } else {


    this.$.output.addContent("failed" + inGoodies);
    }
    })


    ;

    },
    seeAction: function() {
    new enyo.Ajax({ url: "https://www.box.com/api/2.0/folders/0", headers: {"Authorization": "BoxAuth api_key=" +

    this.apikey + "&auth_token="+ this.auth_token}, handleAs: "json"})

    .go(/*{token: this.auth_token, secret: this.auth_secret}*/)

    .response(this, function(inSender, inGoodies) {


    this.$.output.addContent(enyo.json.stringify(inGoodies) + "<br/>");

    });
    }
    });
  • I agree with Ben...would love to see more connectors available...thanks for this!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter