Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
activate-environment: true

- name: Install Dependencies
run: uv sync --locked
run: uv sync --extra dev --locked

- name: Format Check (Black)
run: uv run --no-sync black . --check
- name: Lint Check (Ruff)
run: uv run --no-sync ruff check .

- name: Import Cleanup Check (Autoflake)
run: uv run --no-sync pautoflake ./ --check --quiet
- name: Format Check (Ruff)
run: uv run --no-sync ruff format --check .
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
activate-environment: true

- name: Install Dependencies
run: uv sync --locked
run: uv sync --extra dev --locked

- name: Run Tests
run: uv run --no-sync pytest
4 changes: 3 additions & 1 deletion example_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from playerdatapy.gqlclient import Client
from playerdatapy.gqlauth import AuthenticationType
import asyncio
from playerdatapy.constants import API_BASE_URL

# Build out the query string.
# Our GraphiQL Playground at https://app.playerdata.co.uk/api/graphiql/ is useful for building out and testing the query.
Expand All @@ -18,14 +19,15 @@
}
"""


async def main(session_id: str):
auth = GraphqlAuth(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
type=AuthenticationType.CLIENT_CREDENTIALS_FLOW,
)
client = Client(
url="https://app.playerdata.co.uk/api/graphql",
url=f"{API_BASE_URL}/api/graphql",
headers={"Authorization": f"Bearer {auth._get_authentication_token()}"},
)
response = await client.execute(
Expand Down
1 change: 0 additions & 1 deletion example_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import asyncio
from datetime import datetime, timedelta

Expand Down
1 change: 0 additions & 1 deletion playerdatapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
VideoRecordingAttributes,
)


# Appended manually
from .playerdata_api import PlayerDataAPI

Expand Down
1 change: 1 addition & 0 deletions playerdatapy/auth/authorisation_code_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .authorisation_code_flow_base import AuthorisationCodeFlowBase


class AuthorisationCodeFlow(AuthorisationCodeFlowBase):
"""Handles oauth2 authorisation code flow and token management."""

Expand Down
1 change: 1 addition & 0 deletions playerdatapy/auth/authorisation_code_flow_pcke.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .authorisation_code_flow_base import AuthorisationCodeFlowBase


class AuthorisationCodeFlowPCKE(AuthorisationCodeFlowBase):
"""Handles oauth2 authentication code flow with PKCE and token management."""

Expand Down
3 changes: 1 addition & 2 deletions playerdatapy/auth/base_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import json
import time
from oauthlib.oauth2 import TokenExpiredError
from .configuration import API_BASE_URL
from playerdatapy.constants import API_BASE_URL


class BaseAuthFlow:
"""Base class for OAuth2 authentication flows with token management."""


def __init__(self, client_id: str, token_file: str = ".token"):
self.client_id = client_id
self.token_file = token_file
Expand Down
1 change: 0 additions & 1 deletion playerdatapy/auth/client_credentials_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def __init__(self, client_id: str, client_secret: str, token_file: str = ".token
self.client_secret = client_secret

def authenticate(self, save_token: bool = True) -> dict:

client = BackendApplicationClient(client_id=self.client_id)

self.oauth_session = OAuth2Session(
Expand Down
1 change: 0 additions & 1 deletion playerdatapy/auth/configuration.py

This file was deleted.

1 change: 1 addition & 0 deletions playerdatapy/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_BASE_URL = "https://app.playerdata.co.uk"
6,656 changes: 2,537 additions & 4,119 deletions playerdatapy/custom_fields.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion playerdatapy/gqlauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from playerdatapy.auth.authorisation_code_flow import AuthorisationCodeFlow
from playerdatapy.auth.authorisation_code_flow_pcke import AuthorisationCodeFlowPCKE
from playerdatapy.auth.client_credentials_flow import ClientCredentialsFlow
from playerdatapy.constants import API_BASE_URL


class AuthenticationType(Enum):
Expand Down Expand Up @@ -64,7 +65,7 @@ def _get_authenticated_session(self):
return OAuth2Session(
self.client_id,
token=token,
auto_refresh_url=f"https://app.playerdata.co.uk/oauth/token",
auto_refresh_url=f"{API_BASE_URL}/oauth/token",
token_updater=self.authenticator.save_token,
)

Expand Down
5 changes: 2 additions & 3 deletions playerdatapy/playerdata_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from .gqlauth import GraphqlAuth, AuthenticationType
from .gqlclient import Client
from .base_operation import GraphQLField
from playerdatapy.constants import API_BASE_URL


class PlayerDataAPI(GraphqlAuth):

def __init__(
self,
client_id: str,
Expand All @@ -14,7 +14,6 @@ def __init__(
port: int = 8888,
authentication_type: AuthenticationType = AuthenticationType.AUTHORISATION_CODE_FLOW,
):

super().__init__(
client_id=client_id,
client_secret=client_secret,
Expand All @@ -24,7 +23,7 @@ def __init__(
type=authentication_type,
)
self.client = Client(
url="https://app.playerdata.co.uk/api/graphql",
url=f"{API_BASE_URL}/api/graphql",
headers={"Authorization": f"Bearer {self._get_authentication_token()}"},
)

Expand Down
19 changes: 13 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ classifiers = ["Private :: Do Not Upload"]
readme = "README.md"
requires-python = ">=3.10,<3.13"
dependencies = [
"argparse>=1.4.0",
"graphql-core>=3.2.0",
"httpx>=0.24.0",
"oauthlib>=3.2.0",
"pydantic>=2.0.0",
"requests-oauthlib>=2.0.0",
]

[project.optional-dependencies]
dev = [
"ariadne-codegen>=0.17.0",
"autoflake>=2.3.1",
"black>=25.1.0",
"pylint>=3.3.8",
"pyproject-autoflake>=1.0.2",
"ruff>=0.14.14",
"pytest>=8.4.2",
"pytest-asyncio>=0.24.0",
"requests-oauthlib>=2.0.0",
]

[build-system]
Expand All @@ -41,3 +45,6 @@ enable_custom_operations = true
client_file_name = "gqlclient"
client_class_name = "GraphqlClient"
remote_schema_headers = {"Authorization" = "$AUTH_TOKEN"}

[tool.ruff.lint]
ignore = ["F405", "F403"]
3 changes: 2 additions & 1 deletion tests/auth/test_base_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from playerdatapy.auth.base_flow import BaseAuthFlow

from playerdatapy.auth.configuration import API_BASE_URL
from playerdatapy.constants import API_BASE_URL


class TestBaseAuthFlow:
"""Tests for BaseAuthFlow class."""
Expand Down
Loading