Skip to content

Commit

Permalink
Merge pull request #433 from owencompher/main
Browse files Browse the repository at this point in the history
fix Discord prompt parameter
  • Loading branch information
singingwolfboy committed Apr 8, 2024
2 parents d51d115 + b4da2eb commit 1be747b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion flask_dance/contrib/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def make_discord_blueprint(
scope = scope or ["identify"]
authorization_url_params = {"prompt": "consent"}
if prompt is None:
authorization_url_params["prompt"] = None
authorization_url_params["prompt"] = "none"
discord_bp = OAuth2ConsumerBlueprint(
"discord",
__name__,
Expand Down
22 changes: 20 additions & 2 deletions tests/contrib/test_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@ def test_blueprint_factory():
assert discord_bp.authorization_url_params["prompt"] == "consent"


def test_blueprint_factory_with_prompt():
def test_blueprint_factory_with_prompt_consent():
discord_bp = make_discord_blueprint(
client_id="foo",
client_secret="bar",
scope=["identify", "email"],
redirect_to="index",
prompt="consent",
)
assert isinstance(discord_bp, OAuth2ConsumerBlueprint)
assert discord_bp.session.scope == ["identify", "email"]
assert discord_bp.session.base_url == "https://discord.com/"
assert discord_bp.session.client_id == "foo"
assert discord_bp.client_secret == "bar"
assert discord_bp.authorization_url == "https://discord.com/api/oauth2/authorize"
assert discord_bp.token_url == "https://discord.com/api/oauth2/token"
assert discord_bp.authorization_url_params["prompt"] == "consent"


def test_blueprint_factory_with_prompt_None():
discord_bp = make_discord_blueprint(
client_id="foo",
client_secret="bar",
Expand All @@ -54,7 +72,7 @@ def test_blueprint_factory_with_prompt():
assert discord_bp.client_secret == "bar"
assert discord_bp.authorization_url == "https://discord.com/api/oauth2/authorize"
assert discord_bp.token_url == "https://discord.com/api/oauth2/token"
assert discord_bp.authorization_url_params["prompt"] == None
assert discord_bp.authorization_url_params["prompt"] == "none"


def test_load_from_config(make_app):
Expand Down

0 comments on commit 1be747b

Please sign in to comment.