• felciano

    UPDATE: just confirmed that while I can get your approach to work from Pythonista itself, I'm unable to get it to work from a share sheet. It seems to crash / exit the share sheet during the authentication process.

    Are you able to successfully call your little test script (above) from a share sheet?

    posted in Pythonista read more
  • felciano

    Thanks @bosco. I was following a similar path with one of the stash developers at https://github.com/ywangd/stash/issues/409. I've now installed dropbox via the wheel package, and dependencies via pip. However I've not been able to get to work reliably, at least when called from within a Pythonista script triggered from a share sheet: it crashes immediately on my iPhone (never gets to the stack trace) and on my iPad the code runs but then hangs and hard-crashes at the end (reboots the iPad).

    Curious to know whether you've had better luck? I've done all my work by hand, rather than your more elegant solution to code it automatically. If yours worked I might try a fresh install of Pythonista and your approach.

    posted in Pythonista read more
  • felciano

    Thanks @JonB. I'm looking to cache API keys for Dropbox (see this thread) so "reasonably secure" should probably mean "invisible from access if someone gets access to the device".

    The use case / need is to store short-lived authentication tokens used for Dropbox API calls. Although this pattern-matches against the environment variables option, these tokens need to be refreshed fairly frequently. The refresh is relatively painless/automated, but still results in an updated key values that needs to be stored. I suspect an .env file or similar stored somewhere that the Files app can read it directly is probably not a good solution since these keys might allow access to sensitive information,
    .
    Encrypting a settings file in iCloud at rest might work but I'm not clear how to do that if the python code that would decrypt the data is also stored in iCloud -- wouldn't that mean someone could just read the Python code and figure out how to decrypt it? I might be missing something here.

    I'd prefer something less tied to the Mac ecosystem, but maybe Keychain is the best option to explore?

    posted in Pythonista read more
  • felciano

    For the record, I've also been trying to get an updated version of the official Dropbox library installed via Stash, but no luck. I'm running into the error describe here:

    https://github.com/ywangd/stash/issues/382

    posted in Pythonista read more
  • felciano

    Hi all ---

    Dropbox has started enforcing short-lived OAuth access tokens so it seems that any Pythonista scripts that want to use it will need to know how to either create or refresh access tokens if they've expired. It appears that current versions of the Dropbox Python library include convenience functions for doing this (e.g. get_and_refresh_access_token()) but those are not available in the version of the library that ships with Pythonista.

    Has anyone been able to figure out how to refresh these tokens some other way? Or some other workaround to enable updated tokens to be used in Pythonista scripts?

    Thanks in advance!

    posted in Pythonista read more
  • felciano

    Hi @madivad did you end up finding a solution for this? I need to cache API tokens across Pythonista runs, and am curious to know whether you've found a way to store these outside of the code in a way that is reasonably secure and sharable across devices.

    posted in Pythonista read more
  • felciano

    Thanks @mikael -- I will give that a shot and report back.

    posted in Pythonista read more
  • felciano

    Hi all --

    I'm trying to get Working Copy integration with Pythonista via the "External Files" functionality, so that code can be stored in Github. I am able to access Github repositories to edit and run code from the main Pythonista window, but I can't figure out how to expose one of these scripts as a Share Sheet script in Pythonista.

    In particular, when I'm looking at one of these scripts and choose the little gear icon and tap "Shortcuts... > Share Extension > + [new share extension]", it prompts me to pick the script for the new share extension and my only options are "This iPad" or "iCloud". Is there a way for the script from external files (in this case, Working Copy) to be triggered by the share sheet?

    Thanks!

    posted in Pythonista read more
  • felciano

    I know this is a 3+ year old thread but I still haven't been able to get this to work correctly with Dropbox (or several other apps that expose files through the External Files API).

    I have confirmed that overall the process works as I've been able to get Working Copy to show up as expected as a file provider when I click Pythonista > External Files > Open... However Dropbox always seems to show up disabled and I am unable to browse it to select files.

    Working Copy and Dropbox are both configured as external file providers in the Files app, and I'm able to browse their contents from the Files app. However when trying to browse them from Pythonista, Dropbox remains disabled.

    Is there any other configuration required to fully expose a 3rd party file provider in Pythonista?

    posted in Pythonista read more
  • felciano

    Forgot to reply to close this out: using the get_image version as suggested by @mikael did the trick, at least in terms of saving a second or so in runtime (which is noticeable). Thanks all!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!