Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法授权,错误:Failed to decode JSON #155

Closed
xavieryao opened this issue May 24, 2015 · 29 comments
Closed

无法授权,错误:Failed to decode JSON #155

xavieryao opened this issue May 24, 2015 · 29 comments
Labels

Comments

@xavieryao
Copy link

<D> GET https://bypy-tianze.rhcloud.com/refresh
<D> actargs: None
<D> Params: {u'grant_type': u'refresh_token', u'refresh_token': u'22.62cdcb510d0bbe3d4bb6f34356347fa8.315360000.1731761745.3607558357-1572671'}
<D> HTTP Status Code: 200
<D> Request OK, processing action
<E> [11:02:00] Failed to decode JSON:
Exception:
Traceback (most recent call last):
  File "./bypy.py", line 1504, in __store_json
    r.json()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 793, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

OpenShift also failed. Last resort: refreshing with the JAE server (*** WARNING *** NON-encrypted http protocol) ...
<D> GET http://bypyoauth.jd-app.com/refresh
<D> actargs: None
<D> Params: {u'grant_type': u'refresh_token', u'refresh_token': u'22.62cdcb510d0bbe3d4bb6f34356347fa8.315360000.1731761745.3607558357-1572671'}
<D> HTTP Status Code: 200
<D> Request OK, processing action
<E> [11:02:00] Failed to decode JSON:
Exception:
Traceback (most recent call last):
  File "./bypy.py", line 1504, in __store_json
    r.json()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 793, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

<E> [11:02:00] Token-refreshing on all the servers failed
<E> [11:02:00] FATAL: Token refreshing failed, can't continue.
Quitting...

Not saving Hash Cache since 'dirty' is 'False' and 'force_saving' is 'False'
@xavieryao
Copy link
Author

在删除~/.bypy 文件夹重新授权时成功

@houtianze
Copy link
Owner

是不是里上次用超过一个月了?好像这个是百度那边的问题,本来说好10年内refresh token都没问题,实际上好像超过一个月百度就拧巴了。。

@xavieryao
Copy link
Author

@houtianze 邮件乱码了居然……一直都没事
确实是这个原因。建议这种情况下授权服务器返回合法的JSON信息,来提示错误。现在这样让人摸不着头脑。

@xavieryao
Copy link
Author

另外貌似放在screen里一阵不看着它它就假死了,连已用时间都不走。再resume screen就又恢复了。(RPi)

@houtianze
Copy link
Owner

@xavieryao 嗯,这个我考虑改一下授权服务器。

假死问题还在?还是刷新token前存在的?

@tankiy
Copy link

tankiy commented May 31, 2015

我也出现这个错误,也删除了/.bypy,还是不行

@xavieryao
Copy link
Author

~/.bypy

发自我的 iPad

在 Jun 1, 2015,2:58 AM,tankiy notifications@github.com 写道:

我也出现这个错误,也删除了/.bypy,还是不行


Reply to this email directly or view it on GitHub.

@thisiszw
Copy link

thisiszw commented Jun 5, 2015

[22:50:43] Failed to decode JSON:
Exception:
Traceback (most recent call last):
File "./bypy/bypy.py", line 1504, in **store_json
r.json()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 799, in json
return json.loads(self.text, kwargs)
File "/usr/lib/python2.7/dist-packages/simplejson/__init
.py", line 413, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

[22:50:43] Token-refreshing on all the servers failed
[22:50:43] FATAL: Token refreshing failed, can't continue.

我是最近改了百度云密码后出现的这个问题。 在墙往,应该和walled没有关系吧?

@houtianze
Copy link
Owner

试试bypy.py -c然后重新授权?

@thisiszw
Copy link

thisiszw commented Jun 5, 2015

搞定,多谢

@fanxinwuyou
Copy link

昨天我上传还好好的。
今天就不行了。
要重新授权,但是连不上授权服务器啊。

@houtianze
Copy link
Owner

@fanxinwuyou 贴下log?

@septs
Copy link
Contributor

septs commented Jul 23, 2015

@houtianze 为什么不做 #136

@houtianze
Copy link
Owner

@septs #136 中的环境检查中的一部分以前就已经实现了(比如版本检查,授权文件迁移)。SSL部分比较复杂,貌似有一个旧版本pyOpenSSL造成的的我要重现才想想比较好的解决方案,一直没去弄。

楼主本来的问题,没记错的话,我应该已经加提示进去了。

至于今天这个重新授权的问题,没看到log还不确定是不是本地环境导致的。

@fanxinwuyou
Copy link

帖上log,我用的是树莓派。

pi@raspberrypi ~/yunpan $ sudo bypy.py -v -d syncup
Token file: '/root/.bypy/bypy.json'
Hash Cache file: '/root/.bypy/bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
sys.stderr.encoding = UTF-8
Verbose level = 1

Debug = 1

Loading Hash Cache File '/root/.bypy/bypy.pickle'...
Hash Cache File not found, no caching
[16:13:57] Error while loading baidu pcs token:
[16:13:57] Traceback (most recent call last):
File "/usr/bin/bypy.py", line 1484, in __load_local_json
with open(TokenFilePath, 'rb') as infile:
IOError: [Errno 2] No such file or directory: u'/root/.bypy/bypy.json'

Please visit:
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=q8WE4EpCsau1oS0MplgMKNBn
And authorize this app
Paste the Authorization Code here within 10 minutes.
Press [Enter] when you are done
f862f9fcbbef01edea85189ba820f897
auth_code: f862f9fcbbef01edea85189ba820f897
Authorizing, please be patient, it may take upto 60.0 seconds...
Authorizing with the GAE server ...
GET https://bypyoauth.appspot.com/auth
actargs: None
Params: {u'code': 'f862f9fcbbef01edea85189ba820f897', u'redirect_uri': u'oob'}
[16:15:16] Error accessing 'https://bypyoauth.appspot.com/auth'
[16:15:16] Exception:
('Connection aborted.', error(97, 'Address family not supported by protocol'))
Traceback (most recent call last):
File "/usr/bin/bypy.py", line 1255, in __request_work
params = parsnew, timeout = self.__timeout, verify = self.__checkssl, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 69, in get
return request('get', url, params=params, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 415, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(97, 'Address family not supported by protocol'))

[16:15:16] Function: __server_auth_act
[16:15:17] Website parameters: {u'code': 'f862f9fcbbef01edea85189ba820f897', u'redirect_uri': u'oob'}
[16:15:17] Maximum number (1) of tries failed.
I think you are WALLed, so let's authorize with the OpenShift server ...
GET https://bypy-tianze.rhcloud.com/auth
actargs: None
Params: {u'code': 'f862f9fcbbef01edea85189ba820f897', u'redirect_uri': u'oob'}

@houtianze
Copy link
Owner

@fanxinwuyou 后面你没有再等一下?第一个服务器不行,后面的rhcloud,heroku的也不行?

@fanxinwuyou
Copy link

@houtianze 我在虚拟机里安装ubuntu使用代理,授权成功后。然后拷贝授权后的2个文件到树莓派中。成功搞定。
虽然复杂了点,但还是很高兴搞定了啊。gfw力量太强大了。
在树莓派里我有等啊,直到出现失败的code为止。。
谢谢技术支援。
很好用,尤其是用在树莓派上,百度云我开通了会员,有6T的空间。。好用。

@houtianze
Copy link
Owner

@fanxinwuyou 不客气。这个听起来有点奇怪,除非当时是Openshift和Heroku的服务器都down了才会出现这种情况。

墙这个问题挺讨厌,本来GAE是最稳定的,而且免费配额足够用,可惜大多数人都用不了。。考虑改一下服务器的顺序,把GAE放到最后,这样至少正常情况下多数用户不用浪费1分钟来等授权。

@chovan
Copy link

chovan commented Aug 10, 2015

今天我也出现同样的问题了,用bypy -c 删除授权文件。 再尝试授权就不成功了。 我在墙外...

Please visit:
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=o
ob&response_type=code&client_id=q8WE4EpCsau1oS0MplgMKNBn
And authorize this app
Paste the Authorization Code here within 10 minutes.
Press [Enter] when you are done
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Authorizing, please be patient, it may take upto 60.0 seconds...
Authorizing with the GAE server ...
[09:48:42] Fatal Exception, no way to continue.
Quitting...

@fanxinwuyou
Copy link

@chovan 后来我在虚拟机里多试了几次,成功了,将授权文件拷到树莓派就可以用了。原因可能是服务器一时连不上。
我在墙内。
具体原因我不甚明了。我算是linux小白了。只会用,背后原因不懂。
希望你能尽快没有问题。

@chovan
Copy link

chovan commented Aug 10, 2015

@fanxinwuyou 看到你的留言我又试了一次,这次授权成功了。 谢谢!

@houtianze
Copy link
Owner

GAE的估计是墙发威了,试试最新版吧,现在GAE已经放在最后,前面是红帽和Heroku的服务器,应该没被墙。

@zhaoyxiong
Copy link

现在HeroKu的服务器也被墙了吗? 第一个顺序就是这个, 而且等很久10分钟之后显示失败

@zhaoyxiong
Copy link

Heroku失败了之后切换到了Heroku1, 也是失败

@houtianze
Copy link
Owner

刚查了一下,好像heroku没被墙。试试删掉配置文件重新授权呢?
rm -Rf ~/.bypy
rm -f ~/.bypy.*

@zhaoyxiong
Copy link

zhaoyxiong commented Oct 13, 2021 via email

@zhaoyxiong
Copy link

zhaoyxiong commented Oct 13, 2021 via email

@zhaoyxiong
Copy link

zhaoyxiong commented Oct 13, 2021 via email

@houtianze
Copy link
Owner

刚刚发布了最新版1.7.4,token授权和刷新的问题这次应该是比较彻底的解决了,可以升级试一试:
pip install -U bypy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants