diff --git a/authlib/integrations/starlette_client/apps.py b/authlib/integrations/starlette_client/apps.py index f41454f9..1ebd7097 100644 --- a/authlib/integrations/starlette_client/apps.py +++ b/authlib/integrations/starlette_client/apps.py @@ -1,3 +1,4 @@ +from starlette.datastructures import URL from starlette.responses import RedirectResponse from ..base_client import OAuthError from ..base_client import BaseApp @@ -26,6 +27,10 @@ async def authorize_redirect(self, request, redirect_uri=None, **kwargs): :param kwargs: Extra parameters to include. :return: A HTTP redirect response. """ + + # Handle Starlette >= 0.26.0 where redirect_uri may now be a URL and not a string + if redirect_uri and isinstance(redirect_uri, URL): + redirect_uri = str(redirect_uri) rv = await self.create_authorization_url(redirect_uri, **kwargs) await self.save_authorize_data(request, redirect_uri=redirect_uri, **rv) return RedirectResponse(rv['url'], status_code=302)