patreon-java
patreon-java copied to clipboard
Getting redirect when fatching campaigns
When attempting to use the PatreonAPI#fetchCampaigns, I am getting the following response:
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://www.patreon.com/oauth2/api/current_user/campaigns?include=rewards%2Ccreator%2Cgoals">http://www.patreon.com/oauth2/api/current_user/campaigns?include=rewards%2Ccreator%2Cgoals</a>. If not click the link.
The library is initially trying to hit the url https://www.patreon.com/api/oauth2/api//current_user/campaigns?include=rewards%2Ccreator%2Cgoals
. I haven't made changes to my client code in almost 3 years, so I'm assuming there was an API change?
Same problem here: the library constructs paths with a faulty double-slash //
after the /api
part of the URL. Hitting the correct path manually without the double slash returns the expected result.
In my case, this segment of code created /campaigns/<campaign id>/pledges?page%5Bcount%5D=15
(notice the starting slash), which is then appended here to /api/oauth2/api/
(notice the trailing slash) and creates the problematic path containing //
in the middle the URL. This results in the full final URL being https://www.patreon.com/api/oauth2/api//campaigns/<campaign id>/pledges?page%5Bcount%5D=15
, which returns an HTML error page when called as-is.
This would be fixed by https://github.com/Patreon/patreon-java/pull/34 or the solution it suggests.
Edit: created a PR myself. See #41