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
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.
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)
"""
base = "https://oauth.groupme.com/oauth/authorize?"
base = current_app.config["REDIRECT_URL"]
params = {}
params["client_id"] = client_id
if state:
params["state"] = state
params = params | user_params
urlencoded = urlencode(params)
print(base + urlencode(params))
print(params)
return base + urlencode(params)
if urlencoded:
base += "&"
return base + urlencoded
def get_oauth_auth_url(state: None | str = None):
return build_oauth_auth_url(
current_app.config["CLIENT_ID"],
state
)
def custom_get_oauth_auth(params):
return build_oauth_auth_url(
current_app.config["CLIENT_ID"],
None,
params
)