-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLs are not relative to base_url #336
Comments
Hmm... I think we'll need to update the documentation for this. I had entirely forgotten that the docs state that the However, while I'm willing to give up on relative paths for In the code, this resolution is handled in the |
Looking at the docs of URLObject just using >>> url = URLObject("https://github.com/zacharyvoase/urlobject?spam=eggs#foo")
>>> print(url.relative('another-project'))
https://github.com/zacharyvoase/another-project For instance, the >>> base_url = URLObject('https://www.strava.com/api/v3')
>>> base_url.relative('/routes/123')
URLObject('https://www.strava.com/routes/123')
>>> base_url.relative('routes/123')
URLObject('https://www.strava.com/api/routes/123')
>>> base_url = URLObject('https://www.strava.com/api/v3/')
>>> base_url.relative('/routes/123')
URLObject('https://www.strava.com/routes/123')
>>> base_url.relative('routes/123')
URLObject('https://www.strava.com/api/v3/routes/123') In this case, only the last output is correct. However, I'm not sure if there is a simple way to handle all possible cases for all OAuth providers. Edit: I guess, I should also include the example from the original post: >>> base_url = URLObject("http://localhost:8080/openam/oauth2")
>>> base_url.relative('/userinfo')
URLObject('http://localhost:8080/userinfo')
>>> base_url.relative('userinfo')
URLObject('http://localhost:8080/openam/userinfo') |
The docs say:
With
base_url="http://example.com/oauth2"
andauthorization_url="authorize"
, I get redirected tohttp://localhost:5000/auth/custom/authorize
. Using"/authorize"
with a slash at the beginning redirects tohttp://localhost:5000/authorize
. According to the docs, it should be redirecting tohttp://example.com/oauth2/authorize
.If I use full URLs in order to be able to get to the login, URLs are still not relative when making API requests. For example,
custom.session.get("userprofile")
tries to gethttp://localhost:5000/auth/custom/userprofile
. According to the docs, it should be gettinghttp://example.com/oauth2/userprofile
.I'm using OpenAM, running locally right now for testing. It's a bit involved to set up for oauth, but here's the example Flask app at least:
The text was updated successfully, but these errors were encountered: