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

Transparent support for Gandi PAT #1987

Merged
merged 1 commit into from
Aug 22, 2024
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
2 changes: 1 addition & 1 deletion docs/providers/gandi.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gandi
* ``auth_token`` Specify gandi api key
* ``auth_token`` Specify gandi api key or personal access token

* ``api_protocol`` (optional) specify gandi api protocol to use: rpc (default) or rest
5 changes: 3 additions & 2 deletions src/lexicon/_private/providers/gandi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_nameservers() -> List[str]:

@staticmethod
def configure_parser(parser: ArgumentParser) -> None:
parser.add_argument("--auth-token", help="specify Gandi API key")
parser.add_argument("--auth-token", help="specify Gandi API key or Personal Access Token")
parser.add_argument(
"--api-protocol",
help="(optional) specify Gandi API protocol to use: rpc (default) or rest",
Expand Down Expand Up @@ -269,10 +269,11 @@ def _request(self, action="GET", url="/", data=None, query_params=None):
data = {}
if query_params is None:
query_params = {}
auth_method = "Apikey " if len(self._get_provider_option("auth_token")) <= 24 else "Bearer "
default_headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Apikey " + self._get_provider_option("auth_token"),
"Authorization": auth_method + self._get_provider_option("auth_token"),
}
if not url.startswith(self.api_endpoint):
url = self.api_endpoint + url
Expand Down
Loading