Skip to content

Commit

Permalink
Merge pull request #533 from vicchi/gg-starlette-url-fix
Browse files Browse the repository at this point in the history
Starlette v0.26.0 support and authorize_redirect fix
  • Loading branch information
lepture committed Mar 22, 2023
2 parents 2d5d792 + f991848 commit acde1e9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 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
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 acde1e9

Please sign in to comment.