Patreon / platform-documentation

The API documentation for Patreon
https://docs.patreon.com
Other
30 stars 18 forks source link

Empty results for identity resource (API v2) #36

Closed thiagorova closed 4 years ago

thiagorova commented 4 years ago

Hello. For starters, I'm not sure if the problem is with me or not, to be quite frank. If this is somehow my fault, I'm sorry.

I have a creator account in Patreon and recently I made another, personal one, in order to test the Patreon API for my application. After properly dealing with the OAuth (requesting the identity scope), I made an identity GET request to https://www.patreon.com/api/oauth2/v2/identity. I keep getting the same results:

{
  "data": {
    "attributes": {},
    "id": (numerical value),
    "relationships": {
       "memberships": { data: [] },
      "type": "user"
    },
    ... (I also received the links field, but I'm omitting it here)
  }
}

What bothers me is just that the attributes field is empty (I have not made any pledge yet, so my relationship data being empty is more than expected. I have checked my own account to check if there are any privacy settings, but didn't find anything either.

any help would be greatly appreciated, and thanks again!

VTTAssets commented 4 years ago

You have to request the fields you to query specifially, do you do that? See here, at 2): https://docs.patreon.com/#what-39-s-new

All data attributes and relationships must be explicitly requested with the fields and include query params. In v1, the server would return certain attributes and relationships by default. Now, in v2, no data other than type and id will be returned for a resource unless it is requested.

That means, that you will add query parameters to the URL.

Example

When you are testing that, you will run into an error, because the character [ and ] are not urlencoded, so you need to change that accordingly: [ is %5B and ] is %5D, so fields[user].. becomes fields%5Buser%5D=...

thiagorova commented 4 years ago

aha, thanks a lot! I had actually read that on the docs, but (to be honest) it hadn't really clicked. It makes a lot more sense now! Thanks a lot, and sorry for the trouble!