【问题标题】:CherryPy shuts down unexpectedlyCherryPy 意外关闭
【发布时间】:2018-10-15 17:50:43
【问题描述】:

我正在尝试实现一个 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

【问题讨论】:

    标签: python port jupyter cherrypy fitbit


    【解决方案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 的目标而言,它应该是无关紧要的,除非客户端无法协商令牌。

    【讨论】:

    • 谢谢 cyraxjoe - - - 我最初使用了我的 (CLIENT_ID, CLIENT_SECRET),获得了正确且经过验证的数据。但是现在我正在尝试与朋友的(CLIENT_ID,CLIENT_SECRET)重复练习,但我得到的数据仍然与我的相关......这意味着'客户无法协商令牌' - 是否有解决方案?谢谢!
    • 这两个用于为会话生成令牌。请参阅bubblecode.net/en/2016/01/22/understanding-oauth2/…中的图表
    • 看看这个@cyraxjoe:
    【解决方案2】:
    (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?
    

    【讨论】:

    • 这正常吗? - - - @cyraxjoe,我不这么认为...我的朋友将他的应用注册为客户端,这是一个错误吗?在“OAuth 2.0 应用程序类型”下
    • 所有这些都是正确的。你想让它做什么?或许有误会。您朋友的客户端 ID 和机密信息允许他(客户端应用程序)访问您的数据,因为您是对 fitbit 服务器进行身份验证的人。客户是否可以使用您的数据根据​​他(客户)现在可用的信息向您展示额外的功能,以及无需他(客户,您的朋友)知道您的密码或有可能知道您的密码的重要部分看看吧。
    猜你喜欢
    • 2010-12-03
    • 2014-10-31
    • 2014-01-27
    • 2021-11-17
    • 2013-06-30
    • 2016-04-02
    • 2019-01-31
    • 2014-03-14
    • 1970-01-01
    相关资源
    最近更新 更多