Skip to content

User and password authentication #2

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davert0
Copy link
Contributor

@davert0 davert0 commented Sep 15, 2022

No description provided.

Copy link
Owner

@elchicodepython elchicodepython left a comment

Choose a reason for hiding this comment

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

Hello! 😄

Great feature!! ❤️

After checking the code I want to suggest some changes that in my opinion helps the project to stay clean avoiding implicit actions in the initialization of NocoDBClient. 🌟

raise ValueError("Either сredentials or token must be provided")

if not auth_token and (email and password):
auth_token = JWTAuthToken(self.get_auth_token(email, password))
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure about having a HTTP request in the NocoDBRequestsClient initialization. I suggest creating a class with the purpose of retrieving the AuthToken.

classDiagram
class NocoDBAuthClient {
  << interface >>
   +get_auth_token() AuthToken
}


class NocoDBAuthRequestsClient {
   +get_auth_token() AuthToken
}

NocoDBAuthClient <|-- NocoDBAuthRequestsClient

Loading

Usage example:

auth_client = NocoDBAuthRequestsClient("username", "password")
auth_token = auth_client.get_auth_token()
client = NocoDBRequestsClient(base_uri, auth_token)

self.__session.headers.update(
auth_token.get_header(),
)
auth_token.get_header(),
Copy link
Owner

Choose a reason for hiding this comment

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

This change has nothing to do with the commit.

Suggested change
auth_token.get_header(),
auth_token.get_header(),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants