This commit is contained in:
stupidcomputer 2024-11-10 22:42:39 -06:00
parent 779cc2ccba
commit b552539e29

View File

@ -21,33 +21,32 @@ def group_sharing_url_to_id(url: str) -> str:
return group_id return group_id
def build_oauth_auth_url(client_id: str, state: Optional[str] = None, user_params: Optional[dict] = {}): def build_oauth_auth_url(state: Optional[str] = None, user_params: Optional[dict] = {}):
""" """
Build the OAuth redirect url to GroupMe. Build the OAuth redirect url to GroupMe.
state is optional -- it is usually in reference to the organization in question. state is optional -- it is usually in reference to the organization in question.
If so, state should be set to the organization's `addition_url`. (see schema.sql for info) If so, state should be set to the organization's `addition_url`. (see schema.sql for info)
""" """
base = "https://oauth.groupme.com/oauth/authorize?" base = current_app.config["REDIRECT_URL"]
params = {} params = {}
params["client_id"] = client_id
if state: if state:
params["state"] = state params["state"] = state
params = params | user_params params = params | user_params
urlencoded = urlencode(params)
print(base + urlencode(params)) if urlencoded:
print(params) base += "&"
return base + urlencode(params)
return base + urlencoded
def get_oauth_auth_url(state: None | str = None): def get_oauth_auth_url(state: None | str = None):
return build_oauth_auth_url( return build_oauth_auth_url(
current_app.config["CLIENT_ID"],
state state
) )
def custom_get_oauth_auth(params): def custom_get_oauth_auth(params):
return build_oauth_auth_url( return build_oauth_auth_url(
current_app.config["CLIENT_ID"],
None, None,
params params
) )