通过 Twitch 的桌面应用程序的 OAuth 2.0 授权令牌

问题描述

我一直在寻找一种在用户同意访问后将 OAuth 令牌传递给我的 Python 脚本的方法。首先想到的是设置一个临时的本地服务器来获取令牌并完成。 我发现 a library 支持这一点。据我所知,我应该设置回调 URL 并重定向http://localhost 以便本地网络服务器接收令牌。但是有一个问题,图书馆要我编辑我的主机文件,并在那里放一个该 uri 的假记录,它再次指向我的本地主机,但目前无法正常工作。这是代码

scopes = ['user:read:email','user:read:subscriptions']

service_information = Serviceinformation('https://id.twitch.tv/oauth2/authorize','https://id.twitch.tv/oauth2/token','client_id','client_secret',scopes)
manager = CredentialManager(service_information)
redirect_uri = 'http://localhost:3128'

# Never reaches here
url = manager.init_authorize_code_process(redirect_uri)
_logger.info('Open this url in your browser\n%s',url)

code = manager.wait_and_terminate_authorize_code_process()
_logger.debug('Code got = %s',code)
manager.init_with_authorize_code(redirect_uri,code)
_logger.debug('Access got = %s',manager._access_token)

如果有更好的方法可以做到这一点,或者我的设置方式有什么问题,请告诉我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)