Skip to content

Commit 11f1574

Browse files
authored
Merge pull request #248 from Moustachauve/lint-fix-3
Fix multiple lint errors in oauth2helper.py
2 parents 2acefca + d3d8ea7 commit 11f1574

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

pyhilo/oauth2helper.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1+
"""OAuth2 Helper for Hilo"""
2+
13
import base64
24
import hashlib
35
import os
46
import re
5-
from typing import Any, cast
67

7-
from pyhilo.const import (
8-
AUTH_AUTHORIZE,
9-
AUTH_CHALLENGE_METHOD,
10-
AUTH_CLIENT_ID,
11-
AUTH_SCOPE,
12-
AUTH_TOKEN,
13-
)
8+
from pyhilo.const import AUTH_CHALLENGE_METHOD, AUTH_CLIENT_ID, AUTH_SCOPE
149

1510

1611
class OAuth2Helper:
@@ -30,7 +25,13 @@ def _get_code_challenge(self, verifier: str) -> str:
3025
code = base64.urlsafe_b64encode(sha_verifier).decode("utf-8")
3126
return code.replace("=", "")
3227

33-
def get_authorize_parameters(self):
28+
def get_authorize_parameters(self) -> dict[str, str]:
29+
"""
30+
Returns the parameters required for the authorization request.
31+
32+
Returns:
33+
dict[str, str]: A dictionary containing the authorization parameters.
34+
"""
3435
return {
3536
"scope": AUTH_SCOPE,
3637
"code_challenge": self._code_challenge,
@@ -39,7 +40,23 @@ def get_authorize_parameters(self):
3940
"client_id": AUTH_CLIENT_ID,
4041
}
4142

42-
def get_token_request_parameters(self, code, redirect_uri):
43+
def get_token_request_parameters(
44+
self, code: str, redirect_uri: str
45+
) -> dict[str, str]:
46+
"""
47+
Returns the parameters required for the token request.
48+
49+
This method prepares the payload for the request to exchange an authorization
50+
code for an access token. It includes the necessary parameters for the
51+
authorization code grant type with PKCE.
52+
53+
Args:
54+
code: The authorization code received from the authorization server.
55+
redirect_uri: The redirect URI used in the authorization request.
56+
57+
Returns:
58+
dict[str, str]: A dictionary containing the token request parameters.
59+
"""
4360
return {
4461
"grant_type": "authorization_code",
4562
"code": code,

0 commit comments

Comments
 (0)