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

Fix KeyError when building Auth URL #284

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
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
Loading