PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
785 stars 163 forks source link

is that possible to use other token than those from twitchtokengenerator.com ? #407

Closed loupzeur closed 1 year ago

loupzeur commented 1 year ago

I created a token usinig the following code :

def token(): load_dotenv() url = 'https://id.twitch.tv/oauth2/token' form_data = { 'client_id': os.getenv('TWITCH_CLIENT'), 'client_secret':os.getenv('TWITCH_SECRET'), 'grant_type':'client_credentials', 'scope': ' '.join(['chat:read','chat:edit']) } server = requests.post(url, data=form_data) ret = server.json()['access_token'] return ret

with the code given as example :

`class Bot(commands.Bot):

def __init__(self):
    # Initialise our Bot with our access token, prefix and a list of channels to join on boot...
    super().__init__(token=token(), prefix='?', initial_channels=['...'])

async def event_ready(self):
    # We are logged in and ready to chat and use commands...
    print(f'Logged in as | {self.nick}')
    print(f'User id is | {self.user_id}')

@commands.command()
async def hello(self, ctx: commands.Context):
    # Send a hello back!
    await ctx.send(f'Hello {ctx.author.name}!')`

I simply can't get the code running, it seems the token doesn't have the proper right, but when using a token generated from twitchtokengenerator.com it works .... what scope am I missing ?