Skip to content

Commit

Permalink
Handle URLs from Starlette's url_for() method which post 0.26.0 retur…
Browse files Browse the repository at this point in the history
…ns a URL instance and not a string
  • Loading branch information
vicchi committed Mar 20, 2023
1 parent 2d5d792 commit f991848
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions authlib/integrations/starlette_client/apps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from starlette.datastructures import URL
from starlette.responses import RedirectResponse
from ..base_client import OAuthError
from ..base_client import BaseApp
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f991848

Please sign in to comment.