Thanks for the reply, just to follow up on this if anyone has the same problem.
In Python 3, I was using the default parsing in urllib.parse which was not encoding the parameters properly, you need to use urllib.parse.quote_plus with the following safe chars “?:=&/”.
here is the proper encoding using urllib as a function within my code. note that the rederect_uri comment is for flask apps only.
def redirect_url(self,redirect_uri, scope):
# make sure the redirect uri is stated for external access url_for(...,_external=true)
# scopes can be a string or a list of strings
auth_url='https://id.twitch.tv/oauth2/authorize'
# replace the self.client_id with your client id
client_arg=f'?client_id={self._client_id}'
redirect_url=f'&redirect_uri={redirect_uri}'
response_type='&response_type=code'
state=f'&state={self._state}'
if type(scope) == list:
scope_args='&scope=' + ' '.join(scope)
elif type(scope) == str:
scope_args='&scope='+scope
full_args=client_arg+redirect_url+response_type+state+scope_args
encoded_url=auth_url + urllib.parse.quote_plus(full_args,safe='?:=&/')
return encoded_url