[英]Getting Oauth2 token from twitch in python
from rauth import OAuth2Service
import json
class ExampleOAuth2Client:
def __init__(self, client_id, client_secret):
self.access_token = None
self.service = OAuth2Service(
name="secret",
client_id="secret",
client_secret="secret",
access_token_url="https://id.twitch.tv/oauth2/authorize",
authorize_url="https://id.twitch.tv/oauth2/authorize",
base_url="https://id.twitch.tv/",
response_type="token",
scope="channel%3Amanage%3Apolls+channel%3Aread%3Apolls",
state="secret"
)
self.get_access_token()
def get_access_token(self):
data = {'code': 'bar',
'grant_type': 'client_credentials',
'redirect_uri': 'http://localhost'}
session = self.service.get_auth_session(data=data, decoder=json.loads)
self.access_token = session.access_token
k = ExampleOAuth2Client
print(k.get_access_token())
The code is originally not mine so I don't know exactly how it works.该代码最初不是我的,所以我不知道它是如何工作的。 When I run this it says I need to add positional argument 'self'当我运行它时,它说我需要添加位置参数“self”
You need to initialize the ExampleOAuth2Client object properly.您需要正确初始化 ExampleOAuth2Client object。
Instead of this:而不是这个:
k = ExampleOAuth2Client
It should look something like:它应该看起来像:
k = ExampleOAuth2Client('your-client-id', 'your-client-secret')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.