Patreon / patreon-js

Use the Patreon API via OAuth.
MIT License
151 stars 30 forks source link

Patron email addresses are unavailable via API/client libraries #16

Closed cee-chen closed 6 years ago

cee-chen commented 6 years ago

Hi! Apologies if this is the wrong place for is, as this appears to be an API-wide issue not limited to patreon-js.

I'm using the /campaigns/<campaign_id>/pledges endpoint to fetch (for example) my first 100 patrons. While iterating through the relationships.patron data, it appears only return user ID, type, and related user API link. Is there a way to specify (e.g., in a fields[user] or includes param) that I'd like patron emails to be included in my pledges data?

If not, and if I'm supposed to follow the links.related URL to access the each user's patron profiles - is there some way of passing oAuth or a logged in user session into the public patreon.com/api/user/<user_id> endpoint? Apparently programmatically calling the public API user endpoint (understandably) results in the email field) being entirely missing / returning undefined. However, when I open up the public endpoint in my browser while logged into my Patreon creator account, I do see the email address there, plain as day.

At this point, it feels like the next logical step appears to be spoofing a Patreon login/session via headless Chrome and scraping the email field from the user API endpoint.... but you can probably understand why I'm hesitant to take that step into insanity :) Is there a better direction forward in which you can point me? Zapier appears to have no issue accessing & displaying the email field, so I feel like I must be missing something.

Thanks!

jrsun commented 6 years ago

Hi Constance,

As noted in the JSONAPI spec, relationships only holds references to the data. The actual data lives in included in normalized form.

Please let me know if you have any other issues and best of luck! -Jeffrey

jrsun commented 6 years ago

just as a simple code example, this is what i'm doing:

const access_token = "XXX"

const callback = (promise) => {
}
const patreonAPIClient = patreon(access_token)
const url = jsonApiURL(`/campaigns/123123/pledges`, {
  include: ['patron']
})

patreonAPIClient(url).then(resp => {
    console.log(resp.rawJson.included)
}).catch(reject => {
    console.log(reject)
})
cee-chen commented 6 years ago

Awesome! Thank you for the help!