The latest 7.x-1.x branch doesn't work with the latest Feeds module on Drupal 7.

I get this error when attempting to use OAuth2FeedsFetcher:

Fatal error: Class 'FeedsImportBatch' not found in /var/aegir/platforms/batv-new/sites/all/modules/feeds_oauth/OAuth2HTTPSFetcher.inc on line 7

I'm working on a patch to fix it. I'll post it as soon as it works. :-)

Comments

dsnopek’s picture

Status: Active » Needs work
StatusFileSize
new2.09 KB

Attached is the beginnings of a patch. It removes the compile time errors from trying to use OAuth2HTTPSFetcher, but I still haven't been able to get the module to work. I may look for a different solution rather than trying to fix this module.

dsnopek’s picture

Title: Update for latest Feeds on Drupal 7 » Get OAuth 2.0 working in Drupal 7
StatusFileSize
new7.53 KB

Ok, I've managed to get OAuth 2.0 working minimally against the Google OAuth 2.0 implementation. There are still a bunch of things to implement (namely, using the refresh_token to refresh expired keys) and clean-up, but it works!

infojunkie’s picture

Thanks a lot for this. Please let me know when it's safe to test, and a testing scenario please :-)

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new14.27 KB

This patch is finally ready for review! The latest version will refresh the access token automatically when it expires and it makes minor updates to the OAuth 1.0 support for the changes I made to the DB and API (although I haven't tested it).

I'm using this to make authenticated requests to the YouTube API. In that API, when pulling a video feed, it won't give you the tags unless you are authenticated as the user who owns the video.

I'm using Feeds: YouTube Parser to actually parse the YouTube specific data out of the Atom. Here is the issue in the queue over there: #1880326: can't import youtube keyword tags (add information about feeds_oauth to the docs!)

To actually test that scenerio, you'll need an account on YouTube, with at least one video with some tags on it.

The feed URL will look like:

https://gdata.youtube.com/feeds/api/users/username/uploads?v=2

... except with username replaced by your actual YouTube username.

If you create an importer which uses the "HTTP Fetcher", "YouTube parser", "Node processor" and maps "Tags" to a taxonomy field, you'll notice that it never adds any tags!

To do OAuth 2.0, you'll need to create a project with access to the "YouTube Data API" and add a "Client ID for web applications" in the Google APIs Console: https://code.google.com/apis/console

Use the "HTTPS OAuth 2.0 Fetcher" with the following settings:

Now when you run the import, you should notice that your taxonomy field will get filled with the tags from the YouTube videos!

Sorry for having such a complicated scenerio, but it's what I've been working with. :-)

dsnopek’s picture

Oh, and I forgot to add that after you apply the patch you need to run update.php or drush updatedb because it makes changes to the database schema.

infojunkie’s picture

Thanks, will try this shortly.

infojunkie’s picture

What version of Feeds are you using? Using the latest 7.x-2.x from git, I get an error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /d7/batch?id=145&op=do StatusText: error ResponseText: Recoverable fatal error: Argument 2 passed to FeedsProcessor::process() must be an instance of FeedsParserResult, null given, called in /var/www/d7/sites/all/modules/feeds/includes/FeedsSource.inc on line 358 and defined in FeedsProcessor->process() (line 177 of /var/www/d7/sites/all/modules/feeds/plugins/FeedsProcessor.inc).

I haven't hooked the OAuth fetcher yet, just trying to import videos anonymously.

infojunkie’s picture

dsnopek’s picture

Ah, yeah, sorry - I'm using the 2.x-dev version of feeds_youtube, I had completely forgotten about that. :-)

infojunkie’s picture

Status: Needs review » Fixed

Committed to the latest dev, after testing on a demo site. Thanks!

dsnopek’s picture

Awesome! Thanks so much for taking the time to review and test the patch and get it committed so quickly. It always really feels great to spend a couple days hacking on something and see it get accepted upstream - but I'm not sure I've ever experienced it happen so fast. :-)

@infojunkie++

Best regards,
David.

infojunkie’s picture

Thanks. The timing was right - I am toying with a Feeds-based project these days.

Any interest in co-maintaining Feeds OAuth? :-)

dsnopek’s picture

Thanks for the offer! I would be interested in helping co-maintain Feeds OAuth, at least in the near term. I'd love to help get a full Drupal 7 release out.

infojunkie’s picture

Welcome to the project! I will create some tickets that I see are necessary for the 7.x-1.0 release - let's discuss them.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

westis’s picture

Category: task » feature
Status: Closed (fixed) » Active

I've tried the solution in #4, but got two errors. One I managed to solve, the other not.

The first issue was that I had to set http://[sitename]/feeds/oauth2/callback/youtube as Redirect URI in the Google APIs Console.

The second issue I get now, when trying to import using the Feed Importer I created, is the following error message:
Trying to make a request without a token secret over an unencrypted channel. Use OAuth2Client->setAllowUnprotected(true) to allow this.

What does that mean? I have added the Consumer Secret etc. in the Feed Importer. But this seems to be something else?

westis’s picture

Adding to this and answering my own question: both the site URL and the feed URL must use https.

I also had to add this redirect URI to the Google API Console: http://mydomain.com/feeds/oauth2/callback/youtube

infojunkie’s picture

Status: Active » Closed (fixed)

Thanks for documenting your answer.