fix: retrieve user profile after refreshing twitch creds
This commit is contained in:
parent
5616f0e76d
commit
1452f2076b
7 changed files with 18 additions and 16 deletions
|
|
@ -15,10 +15,10 @@ type: application
|
||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.2.7
|
version: 0.2.8
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "0.2.7"
|
appVersion: "0.2.8"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ image:
|
||||||
# This sets the pull policy for images.
|
# This sets the pull policy for images.
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
# Overrides the image tag whose default is the chart appVersion.
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
tag: "0.2.7"
|
tag: "0.2.8"
|
||||||
|
|
||||||
# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
languages.python.version = "3.12.8";
|
languages.python.version = "3.12.8";
|
||||||
|
|
||||||
enterShell = ''
|
enterShell = ''
|
||||||
|
uv sync
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dotenv.enable = true;
|
dotenv.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "huesoporro"
|
name = "huesoporro"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
description = "Misc Twitch bots"
|
description = "Misc Twitch bots"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [
|
authors = [
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,17 @@ class RefreshAction(BaseModel):
|
||||||
authenticator: TwitchAuthenticator
|
authenticator: TwitchAuthenticator
|
||||||
s: Settings
|
s: Settings
|
||||||
|
|
||||||
async def run(self, user: User):
|
async def run(self, user: User) -> str | None:
|
||||||
is_valid = await self.authenticator.token_is_valid(
|
is_valid = await self.authenticator.token_is_valid(
|
||||||
user.external_auth["twitch"]["access_token"]
|
user.external_auth["twitch"]["access_token"]
|
||||||
)
|
)
|
||||||
|
if is_valid:
|
||||||
|
return None
|
||||||
|
|
||||||
if not is_valid:
|
twitch_auth = await self.authenticator.refresh_token(
|
||||||
new_tokens = await self.authenticator.refresh_token(
|
user.external_auth["twitch"]["refresh_token"]
|
||||||
user.external_auth["twitch"]["refresh_token"]
|
)
|
||||||
)
|
user.external_auth["twitch"]["access_token"] = twitch_auth.access_token
|
||||||
user.external_auth["twitch"]["access_token"] = new_tokens["access_token"] # type: ignore[index]
|
user.external_auth["twitch"]["refresh_token"] = twitch_auth.refresh_token
|
||||||
user.external_auth["twitch"]["refresh_token"] = new_tokens["refresh_token"] # type: ignore[index]
|
await self.user_repo.update(user)
|
||||||
await self.user_repo.update(user)
|
return user.encode()
|
||||||
return user.encode()
|
|
||||||
return None
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ class TwitchAuthenticator(BaseModel):
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return TwitchAuth(**response.json())
|
profile = await self.get_userinfo(response.json()["access_token"])
|
||||||
|
return TwitchAuth(**response.json(), userinfo=profile)
|
||||||
|
|
||||||
async def validate_token(self, access_token: str) -> str:
|
async def validate_token(self, access_token: str) -> str:
|
||||||
response = await self.client.get(
|
response = await self.client.get(
|
||||||
|
|
|
||||||
2
uv.lock
generated
2
uv.lock
generated
|
|
@ -472,7 +472,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "huesoporro"
|
name = "huesoporro"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
source = { virtual = "." }
|
source = { virtual = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "aiosqlite" },
|
{ name = "aiosqlite" },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue