omarryhan/aiogoogle

Bug in `authorization_url` `include_granted_scopes` parameter

Closed this issue · 4 comments

When include_granted_scopes is not passed in as a parameter, the following error occurs:
Screenshot (444)

This is because when you do json.dumps(include_granted_scopes) it bypasses the if statement.

for param_name, param in {
"client_id": client_creds["client_id"],
"response_type": response_type,
"state": state,
"access_type": access_type,
"include_granted_scopes": json.dumps(include_granted_scopes),
"login_hint": login_hint,
"prompt": prompt,
}.items():
if param is not None:
uri += "&"
uri += parse.urlencode({param_name: param})

Maybe something like this instead:

for param_name, param in {
    "client_id": client_creds["client_id"],
    "response_type": response_type,
    "state": state,
    "access_type": access_type,
    "include_granted_scopes": include_granted_scopes,
    "login_hint": login_hint,
    "prompt": prompt,
}.items():
    if param is not None:
        uri += f"&{parse.urlencode({param_name: json.dumps(param) if isinstance(param, bool) else param})}"

Agreed 👍

Also I just noticed that here I used an f-string, not sure if this library is meant to be compatible pre Python 3.6. If so, then you will have to remove it.

Yeah, 3.6 is the oldest version we support. So we should be all good. Thanks for the heads up.

Thanks! will release a new version once CI is done