Skip to content

Commit ac0634d

Browse files
committed
Improve authorization scope types
1 parent b1b26fd commit ac0634d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

todoist_api_python/authentication.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import Any, Literal
44
from urllib.parse import urlencode
55

66
import requests
@@ -17,8 +17,27 @@
1717
from todoist_api_python._core.utils import run_async
1818
from todoist_api_python.models import AuthResult
1919

20+
# task:add - Only create new tasks
21+
# data:read - Read-only access
22+
# data:read_write - Read and write access
23+
# data:delete - Full access including delete
24+
# project:delete - Can delete projects
2025

21-
def get_authentication_url(client_id: str, scopes: list[str], state: str) -> str:
26+
"""
27+
Possible permission scopes:
28+
29+
- data:read: Read-only access
30+
- data:read_write: Read and write access
31+
- data:delete: Full access including delete
32+
- task:add: Can create new tasks
33+
- project:delete: Can delete projects
34+
"""
35+
Scope = Literal[
36+
"task:add", "data:read", "data:read_write", "data:delete", "project:delete"
37+
]
38+
39+
40+
def get_authentication_url(client_id: str, scopes: list[Scope], state: str) -> str:
2241
"""Get authorization URL to initiate OAuth flow."""
2342
if len(scopes) == 0:
2443
raise ValueError("At least one authorization scope should be requested.")

0 commit comments

Comments
 (0)