-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e031d49
commit 2e1a281
Showing
5 changed files
with
51 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
class Auth: | ||
@staticmethod | ||
def get_auth_types() -> list: | ||
return ["accessToken", "developerApiKey", "hapikey"] | ||
return ["access_token", "api_key"] | ||
|
||
@staticmethod | ||
def _has_auth_value(source: dict) -> bool: | ||
return bool(source.get("auth_value")) | ||
def _has_auth_value(source: dict, key: str) -> bool: | ||
return bool(source.get(key)) | ||
|
||
@staticmethod | ||
def choose_auth(options: dict, config: dict) -> dict: | ||
def choose_auth(config: dict, options: dict) -> dict: | ||
auth_types = Auth.get_auth_types() | ||
auth_type = options.get("auth_type") | ||
|
||
if auth_type in auth_types and Auth._has_auth_value(options): | ||
return { | ||
"auth_type": auth_type, | ||
"auth_value": options["auth_value"] | ||
} | ||
if auth_type in auth_types and Auth._has_auth_value(config, auth_type): | ||
return {"auth_type": auth_type} | ||
|
||
config_auth_type = config.get("auth_type") | ||
if config_auth_type in auth_types and Auth._has_auth_value(config): | ||
return { | ||
"auth_type": config_auth_type, | ||
"auth_value": config["auth_value"] | ||
} | ||
else: | ||
for key in auth_types: | ||
if key in config and Auth._has_auth_value(config, key): | ||
return {"auth_type": key} | ||
|
||
return { | ||
"auth_type": None, | ||
"auth_value": None | ||
} | ||
return {"auth_type": None} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters