Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow session to be valid without refresh token provided #574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions supabase_auth/_async/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ async def update_user(self, attributes: UserAttributes) -> UserResponse:
self._notify_all_subscribers("USER_UPDATED", session)
return response

async def set_session(self, access_token: str, refresh_token: str) -> AuthResponse:
async def set_session(
self, access_token: str, refresh_token: Union[str, None] = None
) -> AuthResponse:
"""
Sets the session data from the current session. If the current session
is expired, `set_session` will take care of refreshing it to obtain a
Expand Down Expand Up @@ -1009,8 +1011,6 @@ def _get_valid_session(
return None
if not data.get("access_token"):
return None
if not data.get("refresh_token"):
return None
if not data.get("expires_at"):
return None
try:
Expand Down
6 changes: 3 additions & 3 deletions supabase_auth/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,9 @@ def update_user(self, attributes: UserAttributes) -> UserResponse:
self._notify_all_subscribers("USER_UPDATED", session)
return response

def set_session(self, access_token: str, refresh_token: str) -> AuthResponse:
def set_session(
self, access_token: str, refresh_token: Union[str, None] = None
) -> AuthResponse:
"""
Sets the session data from the current session. If the current session
is expired, `set_session` will take care of refreshing it to obtain a
Expand Down Expand Up @@ -1001,8 +1003,6 @@ def _get_valid_session(
return None
if not data.get("access_token"):
return None
if not data.get("refresh_token"):
return None
if not data.get("expires_at"):
return None
try:
Expand Down
2 changes: 1 addition & 1 deletion supabase_auth/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Session(BaseModel):
documentation for information on how to obtain the provider refresh token.
"""
access_token: str
refresh_token: str
refresh_token: Union[str, None] = None
expires_in: int
"""
The number of seconds until the token expires (since it was issued).
Expand Down