How to check if user is active patron of specific account?

I’m trying to check a user’s patron_status status for a specific Patreon account based on the response object to an identity request that includes an array of memberships. Each membership in the array looks something like this (in JSON);

{
  "attributes": {
    "currently_entitled_amount_cents": 0,
    "last_charge_date": "2020-01-01T22:09:27.000+00:00",
    "last_charge_status": "Paid",
    "lifetime_support_cents": 25000,
    "patron_status": "active_patron",
    "pledge_relationship_start": "2019-01-01T14:03:03.380+00:00"
  },
  "id": "xxxx-xxxx-xxxx-xxxx-xxxx",
  "type": "member"
}

So I’m checking the value of patron_status on the object for the Patreon account I want to check the user’s status on. I’m assuming that I can look this up by the id on the object, but I’m not really sure. I don’t know how to determine a Patreon account’s id, other than the username. But I’m also not sure if the id on this object is actually referring to the relationship, not to the Patreon account.

When I have a memberships array with objects like this, what is the easiest way to check if a user is an active Patron of a specific Patreon account?

For clarity, what I’d like to check is “Is the currently authenticated Patreon user a patron of https://www.patreon.com/localjo ?”.

Also for clarity, I am building a plugin that will work together with the Patreon Connect plugin to check if the currently authenticated Patreon user (the one logged into the WordPress admin with Patreon) is an active patron of another specific Patreon user (in this case, my own, but in general, I hope to make this plugin work for anyone with a similar use-case).

In such a case you would need to have permission from the user to see his/her patronages. Via user’s own auth token created while registering for your site. It shouldnt be possible to do by using only your creator access token.

@codebard Can you clarify the user flow for this? This is what I’m thinking;

  1. A user installs the Patreon plugin and connects their WordPress login to their Patreon account.

  2. Then, the user installs my plugin which uses their own connection to Patreon to check if they’re a patron of mine (or of another developer who writes a plugin with the same flow).

  3. If the authenticated Patreon user is a patron of the developer, they will have access to some patron-only plugin features.

Will this flow work? Does the auth token the user gets when they connect Patreon to their WordPress account have the needed permission? If not, is there any way to extend the access or ask for more permissions? Or will I need to have the user create a completely new access token? (In which case, maybe the existing Patreon plugin wouldn’t be needed for what I want to do, and I should re-implement everything for my plugin).

What are your thoughts?