Skip to content

Commit

Permalink
Change default user fields to include sex
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoni-Czaplicki committed Jul 7, 2024
1 parent b94194f commit 9fb5049
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "usos-api"
version = "0.1.2"
version = "0.1.3"
description = "Asynchronous USOS API for Python"
authors = ["Antoni-Czaplicki <[email protected]>"]
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions usos_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AuthManager:
AUTHORIZE_SUFFIX = "services/oauth/authorize"
ACCESS_TOKEN_SUFFIX = "services/oauth/access_token"
REVOKE_TOKEN_SUFFIX = "services/oauth/revoke_token"
# List of available scopes can be found at https://apps.usos.edu.pl/developers/api/authorization/#scopes
SCOPES = "|".join(["offline_access", "studies"])

def __init__(self, api_base_address: str, consumer_key: str, consumer_secret: str):
Expand Down
12 changes: 9 additions & 3 deletions usos_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def remove_scope(self, scope: str) -> None:
[s for s in self.connection.auth_manager.SCOPES.split("|") if s != scope]
)

async def authorize(self, verifier: str, request_token: str = None, request_token_secret: str = None) -> tuple[str, str]:
async def authorize(
self, verifier: str, request_token: str = None, request_token_secret: str = None
) -> tuple[str, str]:
"""
Authorize the client with verifier and optionally token and token secret.
Expand All @@ -105,7 +107,9 @@ async def authorize(self, verifier: str, request_token: str = None, request_toke
:param request_token_secret: The OAuth token secret obtained from the previous step.
:return: The access token and secret.
"""
return await self.connection.auth_manager.authorize(verifier, request_token, request_token_secret)
return await self.connection.auth_manager.authorize(
verifier, request_token, request_token_secret
)

async def get_authorization_url(self, callback_url: str = "oob"):
"""
Expand Down Expand Up @@ -164,7 +168,9 @@ async def save_access_token_to_file(
"""
if not file_path.endswith(".json"):
raise ValueError("File must be a JSON file.")
access_token, access_token_secret = self.connection.auth_manager.get_access_token()
access_token, access_token_secret = (
self.connection.auth_manager.get_access_token()
)
json_data = {
"access_token": access_token,
"access_token_secret": access_token_secret,
Expand Down
1 change: 1 addition & 0 deletions usos_api/services/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async def get_user(
"id",
"first_name",
"last_name",
"sex",
"email",
"student_number",
"student_programmes",
Expand Down

0 comments on commit 9fb5049

Please sign in to comment.