Prototype a Box Python library with a minimal connection to the UI and application

Bug #1389227 reported by Paul Everitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KARL4
Fix Released
Medium
Chris Rossi

Bug Description

We need to learn more about Box: what it does, how it does it, how we'll use it. Equally, we need to figure out how to drive it from Python, which might even mean making our own Python API.

This ticket is an R&D task. Make a new view in KARL with a single button. Click the button and a file is created in a pre-specified folder. Filename is something random (time.time()) and can contain the same HTML each click.

Along the way, investigate:

- What Python 2.x libraries exist and whether we have to write our own
- What knobs need to be in a config file

A second ticket in lp:1389230 describes a deeper dive on topics that will then lead to actual feature tickets. Neither of the R&D tickets will actually go into detail on specifics of how we are implementing this, as we are still learning.

Tags: box
description: updated
Changed in karl4:
assignee: nobody → Chris Rossi (chris-archimedeanco)
Changed in karl4:
status: New → In Progress
Changed in karl4:
status: In Progress → Fix Committed
Revision history for this message
Chris Rossi (chris-archimedeanco) wrote :

I just made a new 'box' branch. It contains a view that lets you connect to a box account and upload and download files.

To use it, create or log in to your box account, then create an application:

https://app.box.com/developers/services/edit/

It doesn't matter what it's called.

In Karl, switch to the box branch, and add 'box.client_id' and 'box.client_secret' to 'etc/karl.ini', using the values for your Box application.

Start Karl and visit, '/start_box'. It will create a 'box' object in the Karl db and redirect to a view of the box.

Notice that it tells you a redirect_url. Edit your application with the given redirect_url and save the application.

Then use the button provided in Karl to log in and connect Karl to your Box application.

Use the minimal UI to upload and download files.

That's it!

Revision history for this message
Paul Everitt (paul-agendaless) wrote : Re: [Bug 1389227] Prototype a Box Python library with a minimal connection to the UI and application

We’re all dreadfully curious, give us some post-mortem! Don’t wait for the next ticket. :)

—Paul

> On Nov 12, 2014, at 4:26 PM, Chris Rossi <email address hidden> wrote:
>
> I just made a new 'box' branch. It contains a view that lets you
> connect to a box account and upload and download files.
>
> To use it, create or log in to your box account, then create an
> application:
>
> https://app.box.com/developers/services/edit/
>
> It doesn't matter what it's called.
>
> In Karl, switch to the box branch, and add 'box.client_id' and
> 'box.client_secret' to 'etc/karl.ini', using the values for your Box
> application.
>
> Start Karl and visit, '/start_box'. It will create a 'box' object in
> the Karl db and redirect to a view of the box.
>
> Notice that it tells you a redirect_url. Edit your application with the
> given redirect_url and save the application.
>
> Then use the button provided in Karl to log in and connect Karl to your
> Box application.
>
> Use the minimal UI to upload and download files.
>
> That's it!
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1389227
>
> Title:
> Prototype a Box Python library with a minimal connection to the UI and
> application
>
> Status in OSF KARL4:
> Fix Committed
>
> Bug description:
> We need to learn more about Box: what it does, how it does it, how
> we'll use it. Equally, we need to figure out how to drive it from
> Python, which might even mean making our own Python API.
>
> This ticket is an R&D task. Make a new view in KARL with a single
> button. Click the button and a file is created in a pre-specified
> folder. Filename is something random (time.time()) and can contain the
> same HTML each click.
>
> Along the way, investigate:
>
> - What Python 2.x libraries exist and whether we have to write our own
> - What knobs need to be in a config file
>
> A second ticket in lp:1389230 describes a deeper dive on topics that
> will then lead to actual feature tickets. Neither of the R&D tickets
> will actually go into detail on specifics of how we are implementing
> this, as we are still learning.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/karl4/+bug/1389227/+subscriptions

Revision history for this message
Chris Rossi (chris-archimedeanco) wrote :

Gosh, I don't know. I mean, it works. I'm not crazy about the workflow where someone has to log into Box through the web, but I don't see any real way around that. But, other than that, it works. Give it a spin. Peek the code. Happy to answer questions.

Revision history for this message
Paul Everitt (paul-agendaless) wrote :

I looked in karl and osi for the branch, couldn’t find it:

  https://github.com/karlproject/karl/branches/all <https://github.com/karlproject/karl/branches/all>

  https://github.com/karlhosting/osi/branches/all

—Paul

> On Nov 12, 2014, at 4:26 PM, Chris Rossi <email address hidden> wrote:
>
> I just made a new 'box' branch. It contains a view that lets you
> connect to a box account and upload and download files.
>
> To use it, create or log in to your box account, then create an
> application:
>
> https://app.box.com/developers/services/edit/
>
> It doesn't matter what it's called.
>
> In Karl, switch to the box branch, and add 'box.client_id' and
> 'box.client_secret' to 'etc/karl.ini', using the values for your Box
> application.
>
> Start Karl and visit, '/start_box'. It will create a 'box' object in
> the Karl db and redirect to a view of the box.
>
> Notice that it tells you a redirect_url. Edit your application with the
> given redirect_url and save the application.
>
> Then use the button provided in Karl to log in and connect Karl to your
> Box application.
>
> Use the minimal UI to upload and download files.
>
> That's it!
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1389227
>
> Title:
> Prototype a Box Python library with a minimal connection to the UI and
> application
>
> Status in OSF KARL4:
> Fix Committed
>
> Bug description:
> We need to learn more about Box: what it does, how it does it, how
> we'll use it. Equally, we need to figure out how to drive it from
> Python, which might even mean making our own Python API.
>
> This ticket is an R&D task. Make a new view in KARL with a single
> button. Click the button and a file is created in a pre-specified
> folder. Filename is something random (time.time()) and can contain the
> same HTML each click.
>
> Along the way, investigate:
>
> - What Python 2.x libraries exist and whether we have to write our own
> - What knobs need to be in a config file
>
> A second ticket in lp:1389230 describes a deeper dive on topics that
> will then lead to actual feature tickets. Neither of the R&D tickets
> will actually go into detail on specifics of how we are implementing
> this, as we are still learning.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/karl4/+bug/1389227/+subscriptions

Revision history for this message
Chris Rossi (chris-archimedeanco) wrote :
Download full text (3.9 KiB)

Hmm, yep, sorry. I screwed up the git push in some way I still haven't
figured out. But it's pushed now.

On Thu, Nov 13, 2014 at 11:43 AM, Paul Everitt <email address hidden> wrote:

> I looked in karl and osi for the branch, couldn’t find it:
>
> https://github.com/karlproject/karl/branches/all
> <https://github.com/karlproject/karl/branches/all>
>
> https://github.com/karlhosting/osi/branches/all
>
> —Paul
>
> > On Nov 12, 2014, at 4:26 PM, Chris Rossi <email address hidden>
> wrote:
> >
> > I just made a new 'box' branch. It contains a view that lets you
> > connect to a box account and upload and download files.
> >
> > To use it, create or log in to your box account, then create an
> > application:
> >
> > https://app.box.com/developers/services/edit/
> >
> > It doesn't matter what it's called.
> >
> > In Karl, switch to the box branch, and add 'box.client_id' and
> > 'box.client_secret' to 'etc/karl.ini', using the values for your Box
> > application.
> >
> > Start Karl and visit, '/start_box'. It will create a 'box' object in
> > the Karl db and redirect to a view of the box.
> >
> > Notice that it tells you a redirect_url. Edit your application with the
> > given redirect_url and save the application.
> >
> > Then use the button provided in Karl to log in and connect Karl to your
> > Box application.
> >
> > Use the minimal UI to upload and download files.
> >
> > That's it!
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1389227
> >
> > Title:
> > Prototype a Box Python library with a minimal connection to the UI and
> > application
> >
> > Status in OSF KARL4:
> > Fix Committed
> >
> > Bug description:
> > We need to learn more about Box: what it does, how it does it, how
> > we'll use it. Equally, we need to figure out how to drive it from
> > Python, which might even mean making our own Python API.
> >
> > This ticket is an R&D task. Make a new view in KARL with a single
> > button. Click the button and a file is created in a pre-specified
> > folder. Filename is something random (time.time()) and can contain the
> > same HTML each click.
> >
> > Along the way, investigate:
> >
> > - What Python 2.x libraries exist and whether we have to write our own
> > - What knobs need to be in a config file
> >
> > A second ticket in lp:1389230 describes a deeper dive on topics that
> > will then lead to actual feature tickets. Neither of the R&D tickets
> > will actually go into detail on specifics of how we are implementing
> > this, as we are still learning.
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/karl4/+bug/1389227/+subscriptions
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/1389227
>
> Title:
> Prototype a Box Python library with a minimal connection to the UI and
> application
>
> Status in OSF KARL4:
> Fix Committed
>
> Bug description:
> We need to learn more about Box: what it does, how it does it, how
> we'll use it. Equally, we need to figure out how to drive it from
> Python, which might even mea...

Read more...

Revision history for this message
Paul Everitt (paul-agendaless) wrote :

Got it running, it does what it says on the tin, to use a British expression. Most importantly, I think it gives you enough knowledge to reason about the next investigative step lp:1389230

Some questions after reading the code:

1) The idea of making access_token persistent at first gave me the heeby jeebies but then, well, it makes perfect sense.

2) "Work around for lack of 'view_defaults' in earlier version of Pyramid". Sigh.

3) Good catch on the CSRF protection.

4) Did you tackle refresh token issues?

5) Clever approach on returning response.raw

Changed in karl4:
status: Fix Committed → Fix Released
Revision history for this message
Chris Rossi (chris-archimedeanco) wrote : Re: [Bug 1389227] Re: Prototype a Box Python library with a minimal connection to the UI and application

On Mon, Nov 24, 2014 at 3:09 PM, Paul Everitt <email address hidden> wrote:

> 4) Did you tackle refresh token issues?
>
>
Yes, here: (line 157)

https://github.com/karlproject/karl/commit/86ac224e7d355a29918d3ab956725465a4b22b43#diff-585d7687e8a2756ee8b38f57dd4837c4R157

Chris

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.