Skip to content

Commit

Permalink
Remove circuit_breaker and use boto3 to update token on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
minimike86 committed Jul 4, 2024
1 parent 3f7689a commit 48a3c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def get_app_token() -> str:
return client_creds_grant_flow['access_token']


# TODO: Replace with lambda calls
async def check_valid_token(user: any) -> bool:
is_valid_token = await twitch_api_auth_http.validate_token(access_token=user.get('access_token'))
if not is_valid_token:
Expand All @@ -45,6 +46,7 @@ async def check_valid_token(user: any) -> bool:
return is_valid_token


# TODO: Replace with lambda calls
async def refresh_user_token(user: any) -> str:
auth_result = await twitch_api_auth_http.refresh_access_token(refresh_token=user.get('refresh_token'))
try:
Expand Down Expand Up @@ -123,11 +125,15 @@ async def refresh_user_token(user: any) -> str:
f"{Style.RESET_ALL}")
exit(0)

ec2 = boto3.client('ec2')
response = ec2.describe_instances(InstanceIds=['i-0100638f13e5451d8'])
public_dns = response['Reservations'][0]['Instances'][0]['PublicDnsName']

# Create a bot from your twitch client credentials
bot = Bot(app_access_token=app_access_token,
user_token=bot_user.get('access_token'),
initial_channels=[settings.BOT_JOIN_CHANNEL],
eventsub_public_url='https://ec2-3-9-179-105.eu-west-2.compute.amazonaws.com/')
eventsub_public_url=public_dns)
bot.from_client_credentials(client_id=settings.CLIENT_ID,
client_secret=settings.CLIENT_SECRET)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ iso8601==2.0.0
multidict==6.0.4
python-decouple==3.8
PyYAML==6.0
twitchio~=2.9.1
twitchio~=2.10.0
typing_extensions==4.7.0
yarl==1.9.2
vt-py==0.17.5
Expand Down

0 comments on commit 48a3c64

Please sign in to comment.