[php] identifying users membership to my campain

Im working on a project to give a code from my website to active patreon members (unique to each member.) The user is authorizing my site as follows (this is working successfully)

$href = 'https://www.patreon.com/oauth2/authorize?response_type=code&client_id=' . $client_id . '&redirect_uri=' . urlencode($redirect_uri);
$scope_parameters = '&scope=member%20identity'.urlencode('[email]');
$href .= $scope_parameters;
echo '<a href="'.$href.'">Click here to login via Patreon</a>';

at the redirect_uri I am getting the access token from the user. I am then looking at the info from the access token as follows:

$api_client = new API($access_token);
$patron_response = $api_client->fetch_user(["include" => ["pledges"]]);

When I look at $patron_response it includes all memberships the user has ever had, with no obvious way for me to iterate through the array to find my campaign. What am I missing? Ideally I would only get the membership info for my campaign, or at least have someway to identify which one of the campaigns in the ‘included’ array was the campaign I am interested in. any pointers would be appreciated.

I had the same issue.
workarounds:

  • create a new client in your account.
  • or add to include: memberships,memberships.currently_entitled_tiers,memberships.campaign and check tier and campaign id of every membership

Maybe I did something wrong or some of oauth2 clients have more permission than others.
I guess this is a security issue and patreon support needs attention.

Either use your own creator access token to pull the members, or iterate over the memberships and match the membership to your campaign id.

Iterating memberships by using the campaign id is the way to do this.