Oauth 2.0 在Pythonywhere上安装后出现OAuth错误

Oauth 2.0 在Pythonywhere上安装后出现OAuth错误,oauth-2.0,wsgi,bottle,pythonanywhere,fitbit,Oauth 2.0,Wsgi,Bottle,Pythonanywhere,Fitbit,我在本地开发了一个pythonwebapp,并(主要)使用它 也就是说,当我尝试验证一个用户(该用户在我的本地安装上工作)时,会出现以下错误: 重定向\u uri不匹配:null。参观https://dev.fitbit.com/docs/oauth2 有关Fitbit Web API授权流程的更多信息。 我已经更新了fitbit api应用程序设置,并三次检查设置中的重定向uri是否与应用程序中的一致 看看fitbit文档论坛,似乎在哪里 https://www.fitbit.com/logi

我在本地开发了一个pythonwebapp,并(主要)使用它

也就是说,当我尝试验证一个用户(该用户在我的本地安装上工作)时,会出现以下错误:

重定向\u uri不匹配:null。参观https://dev.fitbit.com/docs/oauth2 有关Fitbit Web API授权流程的更多信息。

我已经更新了fitbit api应用程序设置,并三次检查设置中的重定向uri是否与应用程序中的一致

看看fitbit文档论坛,似乎在哪里

https://www.fitbit.com/login?disableThirdPartyLogin=true&redirect=%2Foauth2%2Fauthorize%3Fclient_id%XXXXXXXX%26redirect_uri%3Dhttp%253A%252F%252Fexample.com%252Fcallback%26response_type%3Dcode%26scope%3Dactivity%2Bsleep%2Bweight%2Bnutrition%2Bsettings%26state%3D024

应该是

https://www.fitbit.com/login?disableThirdPartyLogin=true&redirect=%2Foauth2%2Fauthorize%3Fclient_id%XXXXXXXX%26redirect_uri%3Dhttp://example.com/callback%26response_type%3Dcode%26scope%3Dactivity%2Bsleep%2Bweight%2Bnutrition%2Bsettings%26state%3D024

重定向到授权页面的过程如下所示

@app.route('/aas/<study_id>')
def hello(study_id):
    '''This is the primary request page that redirects users to the fitbit api for authorization.'''

    authorization_page = f'https://www.fitbit.com/oauth2/authorize' \
                         f'?response_type=code' \
                         f'&client_id={CLIENT_ID}' \
                         f'&redirect_uri={str(REDIRECT_URI)}' \
                         f'&scope={SCOPE}' \
                         f'&state={study_id}'    
    redirect(url=authorization_page)
@app.route(“/aas/”)
def你好(研究id):
“这是将用户重定向到fitbit api进行授权的主要请求页面。”
授权页面=f'https://www.fitbit.com/oauth2/authorize' \
f'?响应类型=代码'\
f'&client_id={client_id}'\
f'&redirect_uri={str(redirect_uri)}'\
f'&scope={scope}'\
f'&state={study_id}'
重定向(url=授权页面)
有没有一种方法可以阻止这种编码的发生,只是为了看看这是否是问题所在?我想这是由wsgi完成的


非常感谢您的任何其他想法。

谢谢您的关注,各位

原来我没有在授权代码授权流(oauth握手的第二部分)中传递URI,所以

我仍然不知道为什么它在我的本地服务器上工作,而不是在Pythonywhere上,但它是固定的

POST https://api.fitbit.com/oauth2/token
Authorization: Basic Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=
Content-Type: application/x-www-form-urlencoded

client_id=22942C&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fexample.com/callback%2Ffitbit_auth&code=1234567890