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

feat: Added OAuth JWT authorization support #8

Merged
merged 38 commits into from
Jun 25, 2024
Merged

feat: Added OAuth JWT authorization support #8

merged 38 commits into from
Jun 25, 2024

Conversation

Raalsky
Copy link
Contributor

@Raalsky Raalsky commented Jun 20, 2024

No description provided.

@Raalsky Raalsky marked this pull request as draft June 20, 2024 19:59
@Raalsky Raalsky changed the title Draft: feat: Added OAuth support feat: Added OAuth support Jun 24, 2024
@Raalsky Raalsky changed the title feat: Added OAuth support feat: Added OAuth JWT authorization support Jun 24, 2024
@Raalsky Raalsky marked this pull request as ready for review June 24, 2024 08:41
@@ -220,11 +249,39 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
self._client = client
return self

def get_auth_client(self) -> Client:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this method return instance of AuthenticatedClient? (fuction names implies it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this one doesn't care about authorization and it's used for the purpose of token exchange/refresh.

@@ -182,34 +192,53 @@ class AuthenticatedClient:
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
_httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_auth_client: Optional[Client] = field(default=None, init=False)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of _auth_client? Is it a not authorized client that is used to interact with parts of api that do not require any security tokens?

Copy link
Contributor Author

@Raalsky Raalsky Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For token refreshing purposes to prevent cycle over "making a request -> having to refresh token -> making a query to refresh token -> having to refresh token -> ...". I've renamed it to be more self-explaining 😉

src/neptune_api/client.py Outdated Show resolved Hide resolved
src/neptune_api/client.py Show resolved Hide resolved
src/neptune_api/client.py Show resolved Hide resolved
src/neptune_api/credentials.py Outdated Show resolved Hide resolved
templates/errors.py.jinja Outdated Show resolved Hide resolved
src/neptune_api/types.py Show resolved Hide resolved
src/neptune_api/types.py Outdated Show resolved Hide resolved
tests/unit/test_oauth_token.py Outdated Show resolved Hide resolved
@Raalsky Raalsky changed the title feat: Added OAuth JWT authorization support Draft: feat: Added OAuth JWT authorization support Jun 24, 2024
@Raalsky Raalsky changed the title Draft: feat: Added OAuth JWT authorization support feat: Added OAuth JWT authorization support Jun 24, 2024
@Raalsky Raalsky requested a review from szysad June 25, 2024 08:37
)
# TODO: Error handling
data = response.json()
# This should never happen, but just in case
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this should never happen maybe lets log it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, saved for later as we have to figure out how to introduce logger properly that could be controlled via main package.

@Raalsky Raalsky merged commit d06d3f1 into main Jun 25, 2024
6 checks passed
@Raalsky Raalsky deleted the rj/oauth branch June 25, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants