Skip to content

Commit

Permalink
add skip_prompt and fix typings for generate_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
treeben77 committed May 27, 2023
1 parent 8db2d3d commit ebf21d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion discordoauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@ def revoke_token(self, token: str, token_type: str=None):
else:
raise exceptions.HTTPException(f"Unexpected HTTP {response.status_code}")

def generate_uri(self, scope: Union[str, list[str]], state: Optional[str]=None, response_type: Literal["code", "token"]="code", guild_id=None, disable_guild_select=None, permissions=None) -> str:
def generate_uri(self, scope: Union[str, list[str]], state: Optional[str]=None, skip_prompt: Optional[bool]=False, response_type: Optional[Literal["code", "token"]]="code", guild_id: Optional[Union[int, str]]=None, disable_guild_select: Optional[bool]=None, permissions: Optional[Union[int, str]]=None) -> str:
"""Creates an authorization uri with client information prefilled.
scope: a string, or list of strings for the scope
state: optional state parameter. Optional but recommended.
skip_prompt: doesn't require the end user to reauthorize if they've already authorized you app before. Defaults to `False`.
response_type: either code, or token. token means the server can't access it, but the client can use it without converting.
guild_id: the guild ID to add a bot/webhook.
disable_guild_select: wether to allow the authorizing user to change the selected guild
Expand All @@ -271,6 +272,7 @@ def generate_uri(self, scope: Union[str, list[str]], state: Optional[str]=None,
"scope": " ".join(scope) if type(scope) == list else scope,
"state": state,
"redirect_uri": self.redirect_url,
"prompt": "none" if skip_prompt else None,
"response_type": response_type,
"guild_id": guild_id,
"disable_guild_select": disable_guild_select,
Expand Down
1 change: 1 addition & 0 deletions docs/source/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Client

:param Union[str, list[str]] scope: A list, or space-seperated string for the authorization scope
:param Optional[str] state: State parameter. It is recommended for security.
:param Optional[bool] skip_prompt: Doesn't require the end user to reauthorize if they've already authorized you app before. Defaults to ``False``.
:param Optional[Literal["code", "token"]] response_type: either code, or token. token means the server can't access it, but the client can use it without converting.
:param Optional[Union[int, str]] guild_id: the guild ID to add a bot/webhook.
:param Optional[bool] disable_guild_select: wether to allow the authorizing user to change the selected guild
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name='discord-oauth2.py',
description='Use Discord\'s OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation. ',
version="1.2.0",
version="1.2.1",
long_description=long_description,
long_description_content_type="text/markdown",
license='MIT',
Expand Down

0 comments on commit ebf21d6

Please sign in to comment.