微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决通过 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 举报,一经查实,本站将立刻删除。