Skip to content

Commit

Permalink
Fix KeyError when building Auth URL (#284)
Browse files Browse the repository at this point in the history
We were not properly checking the existence of an entry in a dict.
  • Loading branch information
mrashed-dev authored Oct 12, 2023
1 parent 09642f8 commit fd643d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions nylas/models/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CodeExchangeResponse:

access_token: str
grant_id: str
email: str
scope: str
expires_in: int
refresh_token: Optional[str] = None
Expand Down
8 changes: 5 additions & 3 deletions nylas/resources/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def _hash_pkce_secret(secret: str) -> str:
def _build_query(config: dict) -> dict:
config["response_type"] = "code"

if not config["access_type"]:
if "access_type" not in config:
config["access_type"] = "online"

if config["scope"]:
if "scope" in config:
config["scope"] = " ".join(config["scope"])

return config
Expand All @@ -49,7 +49,9 @@ def _build_query_with_admin_consent(config: dict) -> dict:
params = _build_query(config)

params["response_type"] = "adminconsent"
params["credential_id"] = config["credentialId"]

if "credential_id" in config:
params["credential_id"] = config["credential_id"]

return params

Expand Down

0 comments on commit fd643d5

Please sign in to comment.