Integrating FacebookConnect with the existing user login

Feb 7, 2011 at 2:32 AM

Hi there all. Thanks for helping me advance.

I am currently working on a FacebookConnect Module that integrates facebookConnect with the existing user login provided by OrchardCMS. It is part of my school project and we have not been taught about this.
I am also kinda new to C# and the new @Razor Engine and i am lost on how to start :(
Basically the scenario below will explain how my module is to work.

Scenario

Users comes across the site i am running. They want to login to use my advanced features in my site.

User A has an existing facebook account and so he uses his facebook account to connect with my website.
When doing so, she/he automatically becomes a member with "Contributor Role" within my CMS.
He/She also has the permissions like viewing the dashboard and also creating posts in my blog with the CMS.

User B doesn't have a facebook account, therefore he registers an account provided by Orchard CMS.
He/She has the permissions like viewing the dashboard and also creating posts in my blog with the CMS.

 

I am very lost and i would be really thankful if the orchard community can help me with the coding part as i am also running out of time for my project submission.

Thanks alot.

Feb 7, 2011 at 2:43 AM

Are you familiar with the Open Auth Module for Orchard? Take a look at: http://orchardopenauth.codeplex.com/

This is an open source work in progress. It would appear that what they are doing is quite similar to what you want to do.

Feb 7, 2011 at 4:55 AM

@JonnyBoats - Thanks Jonny for the information, but i am not very familiar with the module. I happened to download the source, but i am not able to get it working.

Developer
Feb 7, 2011 at 11:45 AM

@surajsuresh: If you are accustomed to creating Orchard modules (event the most simple ones) - take a look at the http://facebooksdk.codeplex.com/. It provides the C# API to Facebook, so you won't have to deal with the API wrapper yourself. There's also a very good documentation.

If you haven't written Orchard modules before - I'd highly advise you to read the developer docs first. The Orchard Jumpstart module I recently made could be also of great help to you - it contains the basic module functionality you can start with and lots of comments inside.

Cheers, Piotr

Feb 7, 2011 at 1:56 PM

@pszmyd: thanks alot mate(: I will look into them.

Developer
Feb 7, 2011 at 3:07 PM
Edited Feb 7, 2011 at 3:08 PM

No problem:) I'll keep you posted when I find something that would help you further. Cheers

Developer
Feb 19, 2011 at 5:21 PM

@surajsuresh: Just wanted to ask how the module development keeps going?:)

Feb 20, 2011 at 10:03 AM

@pszmyd: Hi there Piotr, i have sent you an email, could you pls help me look into it. Thanks:)

Feb 20, 2011 at 7:46 PM
Edited Feb 20, 2011 at 7:47 PM

I've also done facebook connect integration into my mvc sites, so feel free to ask me any questions as well.

Developer
Feb 21, 2011 at 1:05 PM

Hey guys, I am writing the http://orchardopenauth.codeplex.com/ module. Sorry if it didnt compile when you got latest, best thing to do is to get latest from the dev branch :)

I have just built in oauth wrapper that has linq2twitter integrated with it. Facebook will be the next step, though I may release in to a beta stage before facebook goes in just to get community perception... as feedback is really important to me.

Nick

Developer
Feb 21, 2011 at 1:29 PM

Hi!

Nick, I've been working on the L2T integration too (for messaging purposes), so maybe we'd join forces?:)

Cheers!

Developer
Feb 21, 2011 at 5:37 PM
Edited Feb 21, 2011 at 6:48 PM

sounds good dude. Here is an example of code in another module that will work with my module :-

        private readonly IOAuthTwitterAuthorizer _twitterAuthorizer;
        private readonly IOrchardServices _orchardServices;

        public HomeController(IOAuthTwitterAuthorizer twitterAuthorizer, IOrchardServices orchardServices) {
            _twitterAuthorizer = twitterAuthorizer;
            _orchardServices = orchardServices;
        }

        public ViewResult RetrieveTweets() {
            var twitterCtx = new TwitterContext(_twitterAuthorizer.GetAuthorizer(_orchardServices.WorkContext.CurrentUser));

            var tweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Friends
                select tweet;

            tweets.ToList().ForEach(
                tweet => Console.WriteLine(
                    "Friend: {0}\nTweet: {1}\n",
                    tweet.User.Name,
                    tweet.Text));

            return null;
        }

Note all you need is IOAuthTwitterAuthorizer twitterAuthorizer and then pass this _twitterAuthorizer.GetAuthorize(*/user*/) in to the context. This will work with any user that you have on your system that has a twitter account associated.

Is this what your looking for?

Also blogged http://www.themayneissue.com//memorystream/linq2twitter-open-authentication-module-and-orchard-cms

Mar 8, 2011 at 5:46 PM

Hello,

I setup Facebook Connect in Orchard, but don't understand the Permission setting... What value do I enter here?

Regards,

TJ Havens

Developer
Mar 8, 2011 at 6:59 PM

Facebook requires you to explicitely ask user for specific permissions. This value is a list of string values separated by "," - you can find the list of all available permissions here: http://developers.facebook.com/docs/authentication/permissions/

HTH

Mar 10, 2011 at 10:05 PM

Thank You, that answered my question.

Regards,
TJ Havens

Mar 11, 2011 at 3:31 PM

Hello,

I want to place the Facebook Connect button outside of the available zones, I'm sure using CSS, this can be done, anyone know the selector for the facebook button?

Regards,
TJ Havens

Coordinator
Mar 11, 2011 at 7:32 PM

Why don't you just add a zone where you need it in your theme's layout file and in the theme's manifest?

May 15, 2011 at 10:07 AM

Every time when I try to login with facebook I got next error:

http://pic2net.ru/view/v/5054285af7073a9a208ad2f08d8aa931.jpg

ID, secret and Permissions are set.

May 15, 2011 at 11:07 AM

For 3rd party modules it's best to ask at the module-specific website or contact the owners through Orchard Gallery.