@@ -107,6 +107,9 @@ class StarletteAdapter(BaseAdapter, Starlette):
107107 An optional :class:`str` passed to use as the EventSub secret. It is recommended you pass this parameter when using
108108 an adapter for EventSub, as it will reset upon restarting otherwise. You can generate token safe secrets with the
109109 :mod:`secrets` module.
110+ redirect_path: str | None
111+ An optional :class:`str` passed to use as the path for the Oauth Redirect callback. Defaults to ``/oauth/callback``.
112+ E.g. ``http://localhost:4343/oauth/callback`` or ``https://mydomain.org/oauth/callback``.
110113 ssl_keyfile: str | PathLike[str] | None
111114 An optional SSL key file passed to Uvicorn.
112115 ssl_keyfile_password: str | None
@@ -157,6 +160,7 @@ def __init__(
157160 domain : str | None = None ,
158161 eventsub_path : str | None = None ,
159162 eventsub_secret : str | None = None ,
163+ redirect_path : str | None = None ,
160164 ssl_keyfile : str | PathLike [str ] | None = None ,
161165 ssl_keyfile_password : str | None = None ,
162166 ssl_certfile : str | PathLike [str ] | None = None ,
@@ -184,12 +188,15 @@ def __init__(
184188 path : str = eventsub_path .removeprefix ("/" ).removesuffix ("/" ) if eventsub_path else "callback"
185189 self ._eventsub_path : str = f"/{ path } "
186190
191+ opath : str = redirect_path .removeprefix ("/" ).removesuffix ("/" ) if redirect_path else "oauth/callback"
192+ self ._redirect_path : str = f"/{ opath } "
193+
187194 self ._runner_task : asyncio .Task [None ] | None = None
188195 self ._responded : deque [str ] = deque (maxlen = 5000 )
189196
190197 super ().__init__ (
191198 routes = [
192- Route ("/oauth/callback" , self .oauth_callback , methods = ["GET" ]),
199+ Route (self . _redirect_path , self .oauth_callback , methods = ["GET" ]),
193200 Route ("/oauth" , self .oauth_redirect , methods = ["GET" ]),
194201 Route (self ._eventsub_path , self .eventsub_callback , methods = ["POST" ]),
195202 ],
@@ -215,7 +222,7 @@ def eventsub_url(self) -> str:
215222 @property
216223 def redirect_url (self ) -> str :
217224 """Property returning the fully qualified URL to the OAuth callback."""
218- return f"{ self ._domain } /oauth/callback "
225+ return f"{ self ._domain } { self . _redirect_path } "
219226
220227 async def event_startup (self ) -> None :
221228 logger .info ("Starting %r on %s://%s:%s." , self , self ._proto , self ._host , self ._port )
@@ -405,9 +412,9 @@ def _find_redirect(self, request: Request) -> str:
405412 if host .startswith ((self ._domain , stripped )):
406413 redirect = self .redirect_url
407414 elif host .startswith ((self ._host , local )):
408- redirect = f"{ local } :{ self ._port } /oauth/callback "
415+ redirect = f"{ local } :{ self ._port } { self . _redirect_path } "
409416 else :
410- redirect = f"{ scheme } ://{ host } /oauth/callback "
417+ redirect = f"{ scheme } ://{ host } { self . _redirect_path } "
411418
412419 return redirect
413420
0 commit comments