CherryPy意外关闭

时间:2018-10-15 17:50:44

标签: python port jupyter cherrypy fitbit

我正在尝试实现Jupyter Notebook python练习,我看到了 运行此命令后,我会得到这些注释:

server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET)
server.browser_authorize()
ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token'])
REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token'])
auth2_client = fitbit.Fitbit(CLIENT_ID, CLIENT_SECRET, oauth2=True, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)

我看到了各种解决方案,但没有一个适用,也许我缺少明显的东西。非常感谢您的帮助...我使用python 3,并且在Anaconda的虚拟环境中运行Jupiter ...

这是木星的反应。

[15/Oct/2018:20:35:55] ENGINE Listening for SIGTERM. [15/Oct/2018:20:35:55] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config.

[15/Oct/2018:20:35:55] ENGINE Set handler for console events. [15/Oct/2018:20:35:55] ENGINE Started monitor thread 'Autoreloader'. [15/Oct/2018:20:35:55] ENGINE Serving on http://127.0.0.1:8080 [15/Oct/2018:20:35:55] ENGINE Bus STARTED

127.0.0.1 - - [15/Oct/2018:20:35:57] "GET /?code=72a3a2487757c76b0a07eb37a9c1b915fd69166a&state=D5RsnrJ0HnHD7N3mxYCuL6ZkbUnrB6 HTTP/1.1" 200 122 "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"

[15/Oct/2018:20:35:58] ENGINE Bus STOPPING [15/Oct/2018:20:36:07] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down [15/Oct/2018:20:36:07] ENGINE Stopped thread 'Autoreloader'. [15/Oct/2018:20:36:07] ENGINE Removed handler for console events. [15/Oct/2018:20:36:07] ENGINE Bus STOPPED [15/Oct/2018:20:36:07] ENGINE Bus EXITING

2 个答案:

答案 0 :(得分:1)

https://github.com/orcasgit/python-fitbit / https://python-fitbit.readthedocs.io/en/latest/的上下文中,CherryPy仅用作 处理OAuth2交互以生成令牌的组件。

重要的对象是:

auth2_client = fitbit.Fitbit(CLIENT_ID, CLIENT_SECRET, oauth2=True, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)

只需忽略CherryPy日志,或者如果您真的很在意,然后配置记录器,但是就使用fitbit api的目标而言,它应该是无关紧要的,除非客户端无法协商令牌。

答案 1 :(得分:0)

(MineFitbit) C:\Users\stelios ioannides\Documents\TT_Fitbit\python-fitbit>python gather_keys_oauth2.py [OAuth 2.0 Client ID] [Client Secret]

[24/Oct/2018:22:17:18] ENGINE Listening for SIGTERM.
[24/Oct/2018:22:17:18] ENGINE Bus STARTING
[24/Oct/2018:22:17:18] ENGINE Set handler for console events.
CherryPy Checker:
The Application mounted at '' has an empty config.

[24/Oct/2018:22:17:18] ENGINE Started monitor thread 'Autoreloader'.
[24/Oct/2018:22:17:18] ENGINE Serving on http://127.0.0.1:8080
[24/Oct/2018:22:17:18] ENGINE Bus STARTED
127.0.0.1 - - [24/Oct/2018:22:18:28] "GET /?code=a0c69fd0ba0e891f3ca223c7455015e29ad32c26&state=sZbyzbohIWntkp4mXPJTAFGDrlHnzV HTTP/1.1" 200 122 "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"
[24/Oct/2018:22:18:29] ENGINE Bus STOPPING
[24/Oct/2018:22:18:39] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down
[24/Oct/2018:22:18:39] ENGINE Stopped thread 'Autoreloader'.
[24/Oct/2018:22:18:39] ENGINE Removed handler for console events.
[24/Oct/2018:22:18:39] ENGINE Bus STOPPED
[24/Oct/2018:22:18:39] ENGINE Bus EXITING
[24/Oct/2018:22:18:39] ENGINE Waiting for child threads to terminate...
[24/Oct/2018:22:18:39] ENGINE Bus EXITED
[24/Oct/2018:22:18:39] ENGINE Waiting for thread Thread-14.
You are authorized to access data for the user: stelios ioannides
TOKEN
=====

access_token = [eliminated for security]
expires_in = 28800
refresh_token = [eliminated for security]
scope = ['activity', 'location', 'weight', 'profile', 'heartrate', 'sleep', 'social', 'settings', 'nutrition']
token_type = Bearer
user_id = [eliminated for security]
expires_at = 1540437508.9480457

(MineFitbit) C:\Users\stelios ioannides\Documents\TT_Fitbit\python-fitbit

**AS you can see I entered another person's credentials and i still get MY data...WHY?** the user stelios is ME...Why is this happening?