Facebook and YouTube APIs


(Ellis Taylor) #1

Hi all,

 

I'm currently putting together a bit of a social hub section and having a few issues grabbing the data from their respective providers.

 

Twitter is fine, I've managed to get the data through the REST Resource and REST Resource OAuth Session assets and now want to do a similar thing for Facebook and YouTube. Both services seem to use slightly different strains of OAuth and I need to pass in values for the OAuth authentication - 'Request Token Request URL' , 'Authorization Request URL' and 'Access Token Request URL' but I'm not totally sure what these would be for the Facebook Graph API or the YouTube Data API, I've tried a few combinations but have had no luck.

 

Unlike when I preview the Twitter REST Resource OAuth Session, I get no redirect, just a completely blank page. Has anyone had any experience in setting either of these APIs up within Matrix, if so any assistance would be hugely appreciated.

 

Please let me know if anyone needs more info.

 

 

Cheers!

Ellis

 

 


(Ellis Taylor) #2

Hi guys,

 

Further to my initial post. I just thought I'd drop in that I've managed to authenticate a YouTube request via an 'OAuth2 Token' asset as they seem to be a bit more flexible in their feedback but these expire every hour so probably aren't that practical.

 

Let me know if anyone else has any ideas.

 

 

 

Cheers!

Ellis


(Tbaatar) #3

Hi Ellis,

 

Did you use Oauth 1.1? and which version of Matrix are you using the authenticate to Twitter?

 

I tried to authenticate the Twitter application with Matrix Rest OAuth Session asset but failed to generate the access token as described in the manual.

 

Can you please share your steps?

 

 

Thanks.


(Ellis Taylor) #4

Hey,

 

Yeah no problem. It runs off of 1.1 and we run 4.18.0. I've seen there's a few issues with older versions.

 

First off, I created an app on Twitter to get all of the details and set the callback URL to what will be the 'REST Resource OAuth Session', in my case, http://www.herts.ac.uk/_designs/oauth/twitter-rest-oauth-app.

 

Then created a REST Resource OAuth Session asset. Chuck in your consumer key, and consumer secret, switch method to GET, enter the 3 URLs which are provided in the Twitter App interface but for reference are: https://api.twitter.com/oauth/request_token, https://api.twitter.com/oauth/authorize and https://api.twitter.com/oauth/access_token, set the callback URL to what you had in the Twitter App, in my case: http://www.herts.ac.uk/_designs/oauth/twitter-rest-oauth-app, ensure the signature method is HMAC-SHA1. At this point, you will see the OAuth details are set to none, however, if you preview your REST Resource OAuth Session you should start to get redirected to Twitter. Once this process is completed refresh your details screen of the OAuth Session and you should have the authentication. Switch 'Store Access Token' to 'Yes'.

 

 

Lastly I just created a new REST Resource Javascript and entered my API URL in the URLs section and set the 'Authentication Type' to 'OAuth', click commit and when the screen reloads go back to 'Authentication Type' and use the asset picker to include your OAuth Session. Hit 'Run Test' and see what your results you get.

 

 

I've included a couple of screenshots (minus my consumer secret ;) ) for reference.

 

I hope this helps.

 

 

Cheers,

Ellis

Screen Shot 2014-05-13 at 19.08.16.png (41.8 KB) Screen Shot 2014-05-13 at 19.12.23.png (58.7 KB)

(Tbaatar) #5

Thanks Ellis,

 

I will try your method, but it does look like what I did before and I have tried this on v4.18.2


(Bart Banda) #6

Not sure about YouTube, but for facebook you need to use Oath2 as the authentication method. There is a brief tutorial on how to set up an authentication login process on the manuals which might help: http://manuals.matrix.squizsuite.net/oauth2/examples/oauth2-authentication-facebook 

 

Does that help at all?


(Ellis Taylor) #7

Hi Bart,

 

I did eventually work it out for both of them and did it via OAuth2 Token for both.

 

For Facebook I just ran the app key on the server as part of the query in the URL.

 

YouTube was different again in that the OAuth token expired every hour so had to provide an offline_access query string parameter which created the refresh token in Matrix.

 

Now all three of them seem to work okay.

 

 

Thanks for that!

Ellis


(N Wallis) #8

Hi Bart,

 

I did eventually work it out for both of them and did it via OAuth2 Token for both.

 

For Facebook I just ran the app key on the server as part of the query in the URL.

 

YouTube was different again in that the OAuth token expired every hour so had to provide an offline_access query string parameter which created the refresh token in Matrix.

 

Now all three of them seem to work okay.

 

 

Thanks for that!

Ellis

 

Hi Ellis, 

 

I am trying to do the same thing.  Pull in feeds from Facebook, Twiitter and any other social networks we can.  To begin with, I am looking at Facebook. 

 

I have already written a custom PHP application that can do this, it generates some JSON data for use with an asset listing.  Works fine. 

 

For ease of mainteance, I would prefer to be able to move this into Matrix.  We have a number of Facebook accounts and I want to authenticate each of them, have you got an suggestions for this?  I can't quite figure out how it translates to the wonderful world of Matrix.  For example:

 

- How do I request different permissions that my app wants from the user who logs in

- Where does the token get stored that facebook returns?

 

Thanks,

Nathan