koalalorenzo/python-digitalocean

get_all_droplets() fails with exception

Closed this issue · 2 comments

Hi,

get_all_droplets() fails with exception.

$ uname -a
Darwin KOCMOC-mini 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

$ pip show python-digitalocean
Name: python-digitalocean
Version: 1.12
Summary: digitalocean.com API to manage Droplets and Images
Home-page: https://github.com/koalalorenzo/python-digitalocean
Author: Lorenzo Setale ( http://who.is.lorenzo.setale.me/? )
Author-email: lorenzo@setale.me
License: LGPL v3
Location: /Library/Python/2.7/site-packages
Requires: requests

$ python -V
Python 2.7.10

Step to reproduce:

$ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import digitalocean
>>> manager = digitalocean.Manager(token="<token>")
>>> my_droplets = manager.get_all_droplets()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/digitalocean/Manager.py", line 55, in get_all_droplets
    data = self.get_data("droplets/", params=params)
  File "/Library/Python/2.7/site-packages/digitalocean/baseapi.py", line 167, in get_data
    'Read failed from DigitalOcean: %s' % str(e)
digitalocean.baseapi.JSONReadError: Read failed from DigitalOcean: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
>>> ^D
$

Same behaviour on Ubuntu 16.04 with Python 2.7.12.
Also tested on both macOS and Ubuntu with python-digitalocean 1.11 - same behaviour

Could you please take a look?
Grazie mille!

Check #213, probably this is due to a token that has no permission, or that expired... or something like that! Try to re-generate the token with the right permissions, and then use it!

Thank you very much for prompt reply! Yes, token regeneration resolved the issue, despite of the fact that token was listed as active and had read/write permissions.