Open glacials opened 6 years ago
Hey, I just tried out the example and hit an error. I updated the url to use /api instead, and now it's working (for me at least). The pull request is over here https://github.com/Patreon/patreon-ruby/pull/8. Can you try this out and let me know if it fixes it for you?
Hey, actually, I don't think that will help you. Instead, if possible can you run with DEBUG=1
set in your env (and use master of this gem). It will capture some debug output, and then, if you don't mind using some secure method, or cutting out the tokens, I think that will help us track down the issue.
Seeing this issue as well. Using master branch from github didn't help.
Getting this error as well.
@joshbuddy
I re-ran it with DEBUG=1
. I'm not very familiar with these responses and am not sure which parts are sensitive data. Do you have any secure methods you recommend for sharing the output?
Encountering the same problem here. Appears to be an issue with JSON::Api::Vanilla.parse
. Why not just use native Ruby JSON.parse?
From: /patreon-ruby/lib/patreon/api.rb @ line 34 Patreon::API#get_parse_json:
31: def get_parse_json(suffix)
32: json = get_json(suffix)
33: binding.pry
=> 34: parse_json(json) 35: end
[1] pry(#<Patreon::API>)> json
=> "{\n \"data\": {\n \"attributes\": {\n \"about\": null,\n \"created\": \"2017-03-27T22:39:59+00:00\",\n \"discord_id\": null,\n \"email\": \"wak@wakproductions.com\",\n \"facebook\": null,\n \"facebook_id\": null,\n \"first_name\": \"Greenspud\",\n \"full_name\": \"Greenspud Trades\",\n \"gender\": 0,\n \"has_password\": true,\n \"image_url\": \"https://c10.patreonusercontent.com/3/eyJ2IjoiMSIsInciOjIwMH0%3D/patreon-media/user/5462977/a152f52e08ec4099b3212547e377a954?token-time=2145916800&token-hash=96pPoipGZzm6gTSV1dzdQsuIr47TbCzn1wzvW_7UAog%3D\",\n \"is_deleted\": false,\n \"is_email_verified\": true,\n \"is_nuked\": false,\n \"is_suspended\": false,\n \"last_name\": \"Trades\",\n \"social_connections\": {\n \"deviantart\": null,\n \"discord\": null,\n \"facebook\": null,\n \"spotify\": null,\n \"twitch\": null,\n \"twitter\": null,\n \"youtube\": null\n },\n \"thumb_url\": \"https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInYiOiIxIiwidyI6MTAwfQ%3D%3D/patreon-media/user/5462977/a152f52e08ec4099b3212547e377a954?token-time=2145916800&token-hash=FioodKfrYEtzdXUmk5EXJ8KpY3PIKtJFeG6HaIbjZJA%3D\",\n \"twitch\": null,\n \"twitter\": null,\n \"url\": \"https://www.patreon.com/greenspudtrades\",\n \"vanity\": \"greenspudtrades\",\n \"youtube\": null\n },\n \"id\": \"5462977\",\n \"relationships\": {\n \"pledges\": {\n \"data\": []\n }\n },\n \"type\": \"user\"\n },\n \"links\": {\n \"self\": \"https://www.patreon.com/api/user/5462977\"\n }\n}"
[3] pry(#<Patreon::API>)> JSON::Api::Vanilla.parse(json)
NoMethodError: undefined method `pledges=' for nil:NilClass
Can confirm that this is issue with JSON::Api::Vanilla.parse
. I have the same issue in another place #23
JSON::Api::Vanilla
has issue opened https://github.com/trainline/json-api-vanilla/issues/4 from some time ago.
Patreon should drop this dependency.
Temporary workaround:
In Gemfile
use my fork:
# Patreon
gem 'patreon', git: 'https://github.com/hovancik/patreon-ruby', branch: 'feature/remove-json-api-vanilla'
Then update your code to not use broken json-api-vanilla
, ie to get all your patron IDs:
api_client = Patreon::API.new(ENV.fetch('PATREON_ACCESS_TOKEN'))
campaign_response = api_client.fetch_campaign
campaign_id = campaign_response['data'][0]['id']
all_pledges = []
cursor = nil
loop do
page_response = api_client.fetch_page_of_pledges(campaign_id, count: 25, cursor: cursor)
all_pledges += page_response['data']
next_page_link = page_response['links']['next']
break unless next_page_link
parsed_query = CGI::parse(next_page_link)
cursor = parsed_query['page[cursor]'][0]
end
all_pledges.map { |pledge| pledge['relationships']['patron']['data']['id'] }
Thanks @hovancik . I was getting crazy with the Vanilla parse. This workaround works great.
After upgrading the Patreon gem to
v0.3.0
, performing the OAuth flow using the following code snippet throws an exception on the last line during the callback to my service. Downgrading the Patreon gem tov0.2.0
solves the error.Initial sendover:
Callback:
I don't see any patch notes so I'm unsure if this is an intentional change in how the gem should be used, or a bug.
I'm running Rails 5.1.4 on Ruby 2.4.2. Full trace is below. Thanks for any assistance!