Problem getting campaign posts with OAuth2

Hi,

I’m trying to make a program to get the private posts of this campaign. I have an account that pledged to that campaign, so in my account i have access to those private posts, I’m just trying to get their info programmatically.

To that end, I made an oauth client by following all the steps described in the oatuh docs.
Using the oauth process I’m successfully getting the secret token, so I think that’s not the problem. The problem is that when I hit the campaign posts endpoint, it returns me an empty result:

{
  "data": [],
  "meta": {
    "pagination": {
      "total": 0
    }
  }
}

The url for the requests I’m using is: https://www.patreon.com/api/oauth2/v2/campaigns/293332/posts?fields[post]=title
Note that the url requests for specific fields by including the ?fields[post]=title query param.

The scope of the token includes campaigns.posts as requested by the docs. All the scopes of the token are: campaigns campaigns.posts identity identity.memberships campaigns.members campaigns.members[email] campaigns.members.address

Can you try using the same call using your creator token?

It gives me the exact same empty result. It was actually one of the first things I tried, but since the docs asked for the campaigns.posts scope, I thought the problem could be the creator token not having this scope and decided to make a client implementing the full OAuth2 flow. That was my way of making sure the scope was correct.

I also did a double check to see if I didn’t get the campaign id wrong, and it seems correct too. Asking for info about this campaign, I got:

{
  "data": {
    "attributes": {
      "creation_name": "Maluco Beleza",
      "url": "https://www.patreon.com/malucobelezapodcast"
    },
    "id": "293332",
    "type": "campaign"
  },
  "links": {
    "self": "https://www.patreon.com/api/oauth2/v2/campaigns/293332"
  }
}

which is indeed the campaign I want. The result above was the same with the creator token and with the token obtained via OAuth. It’s just the posts endpoint that seems to not be working for me

That’s a good lead. Since creator token has all the related scopes, you should be able to pull posts. If that’s not happening, the call may have an issue. You can check how the WP plugin does posts call to compare to your own call:

/posts calls in the above class could help.

I have this exact problem, I include the correct campaigns.posts scope, I use the creator token and I send the correct request for getting posts, but they’re always empty.

The sign in process also doesn’t show the campaigns.posts, even if it’s included in the
url (I include all scopes)

Screenshot_20201128_012354

I checked that code and the way it is calling the API seems to be the exact same way I’m doing. The only real difference is that they include the ?page[count]=<page_size> query param. I went back to my requests and added that parameter too. Got the exact same empty result as before.

I do have an Wordpress installation for tests lying around, so I decided to go ahead and install the plugin and call that class directly in a page:

$p = new Patreon_API("<secret_token>");
echo "Getting Posts...<br>";
$res = $p->get_posts(293332);
echo "Posts: ";
print_r($res)

The output:

I can reproduce this. I also noticed that when I was doing the OAuth flow. I thought it was weird but didn’t think too much about it. But now that you pointed that out and on second thought, this might be a clue that maybe they silently dropped support for this. Or maybe a bug in the API, since the wordpress plugin uses it too?

WP plugin is installed over 4000 sites, with a lot of them using post sync. I can sync posts without an issue in my test install.

Are saying that you are having issues while doing oauth as well?

I don’t have problems with oauth.

I’m not sure how post sync works, but I imagine it syncs the posts in your account to your wordpress, using your creator token.

If that’s how it works, it’s slightly different from the use case I’m presenting here. My use case is getting the posts from another creator I have a pledge on (hence I have access to their private posts) with my creator token. That’s what’s not working.

As a test, I created a sample post in my campaign and was able to retrieve it using the posts endpoint. I imagine post sync does something similar to this. But that’s not quite what I’m interested in. I want to get access to another’s creator posts.

I’m trying to fetch my own posts from my campaign (ie. the one associated to the oauthed account) and I still can’t do it, it always returns an empty array. Both scopes and the request are correct and I’ve doubled checked with the WP code as well :sob:

@codebard in your test, do you get any mention about posts on Patreon’s page during the oauth? I don’t understand why it’s the only scope not shown there, while all others are visible

Yes, that is correct, posts are synced using creator token. You may not be able to sync posts of a different user.

Posts should not be included in the scopes like that and you should be able to get your posts with your creator token without issues. You can try using the exact calls which the WP plugin is using and see if that produces a result.

Why would posts not show up in the scopes list while other scopes would?

Just to confirm, you’re using the creator token from the oauth, and not one manually generated from the Patreon website, is that correct?

Either should work as long as they are the creator token. Wp’s setup wizard can create it, as well as going to register clients page and creating it yourself.

Hey @xdmx, were you able to figure out how to pull the posts from the campaign associated with the oauth? Having the same exact issue as you.