Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am struggling to find the correct permissions to fix this error.
If my editor role creates a new feed node for twitter it receives this error when it runs.
Failed to fetch data from url "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=quak..." (HTTP response code 400 Bad Request): {"errors":[{"message":"Bad Authentication data","code":215}]}
If I edit the feed node and change the author to 'admin' it runs fine, I switch it back and receive the error again. Is there someplace I'm missing a correct permissions setting?
Thanks!
Comments
Comment #1
dsnopekThis isn't a permission thing - it's because the authentication tokens are saved per user. So, when you do the OAuth dance, that token get's saved for your UID. But when another user goes to use it, it will look for the token for their UID, but it won't find it.
I'm not sure what the correct general solution is here...
Comment #2
chrsnlsn CreditAttribution: chrsnlsn commentedThanks for the insight.
So just as a band-aid I could manually enter the same token secret site id into feeds_oauth_access_tokens with a different UID and it would work for that user as well? I am going to try this out as I only have a couple editors that will be adding these twitter feeds.
Comment #3
dsnopekYes, that should work! I actually do this for my feeds that run as cron, which by default gets the uid of 0.
Comment #4
infojunkiedsnopek's explanation is correct - access tokens are saved per user.
Keeping this as a feature request to support site-wide or group access tokens.
Comment #5
chrsnlsn CreditAttribution: chrsnlsn commentedIf this is going to be a feature request....
Just an idea, not sure how many people are using this to interact with Twitter and are also running the twitter module, but would it be possible to have a checkbox for using the site's twitter info that's already stored here
admin/config/services/twitter/settings
Might be easier to leverage that instead of coding another form to store the same access info.
Comment #6
infojunkieChrisNelson, the feature of acquiring access tokens from another module is already implemented - please check the section "Compatibility with other OAuth modules" on the module's page.
To use this feature, implement
hook_feeds_oauth_authenticator
in your module as per the doc, then select Twitter in your importer's OAuth Fetcher's settings > "OAuth authenticator" section.If this is enough for you, please mark this issue as fixed.
Comment #7
chrsnlsn CreditAttribution: chrsnlsn commentedOh it's all working for me now after editing the database directly and adding another line to the feeds_oauth_access_tokens table. I thought you changed it to feature request and were going to leave it open until an admin interface form was created for adding records to that table. I can mark this as fixed though if you'd like.
Comment #8
kscheirerSounds like it got fixed? Based on #6 and #7.
Comment #9
dsnopekI think there still is a fundamental problem of how to scheduled feeds get their tokens (since tokens are attached to users and scheduled feeds are run as anonymous) and there should be an issue somewhere tracking the resolution of that. However, I do think the users who were originally asking for support here got workarounds that work for them! So, fixed for these users, but there is still an open problem that should get resolved eventually. :-)
@kscheirer: I can't wait until Mixpanel (my module awaiting TSM review), gets this level of scrutiny as well! ;-)
Comment #10
kscheirerHow about a config setting that let's you pick a uid when grabbing the feeds? The selected user would have to have valid tokens.