0
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'

1 Answer 1

1

You need to initialize the ExampleOAuth2Client object properly.

Instead of this:

k = ExampleOAuth2Client

It should look something like:

k = ExampleOAuth2Client('your-client-id', 'your-client-secret')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.