[ColdBox-4.1.0]: Calling Socialite module

I was wondering if any of you has used Socialite module from ForgeBox.

In my handler:
property name=“socialite” inject=“Socialite@Socialite”;

ModuleConfig.cfc

component {
// Module Properties

this.title = “Socialite”;
this.author = “”;
this.webURL = “”;
this.description = “”;
this.version = “1.0.0”;
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
this.viewParentLookup = false;
// If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa
this.layoutParentLookup = true;
// Module Entry Point
this.entryPoint = “socialauth”;
// Model Namespace
this.modelNamespace = “Socialite”;
// CF Mapping
this.cfmapping = “Socialite”;
// Module Dependencies
this.dependencies = [];

function configure(){
// module settings - stored in modules.name.settings

settings = {
oauth = {
facebook = {
client_id = “159181544107035”,
client_secret = “13d20a30524e4aebcbb4a9e7b95f07fe”,
redirect_url = “http://dev.dates.com/socialauth/provider/response/facebook
}
}
};

// SES Routes
routes = [
// Module Entry Point
{pattern="/provider/response/:provider", handler=“home”,action=“response”},
{pattern="/provider/:provider", handler=“home”,action=“auth”},
{pattern="/", handler=“home”,action=“index”},
// Convention Route
{pattern="/:handler/:action?"}
];

// Binder Mappings
// binder.map(“Alias”).to("#moduleMapping#.model.MyService");

// Look for module setting overrides in parent app and override them.
var coldBoxSettings = controller.getSettingStructure();
if( structKeyExists( coldBoxSettings, ‘oauth’ ) ) {
structAppend( settings.oauth, coldBoxSettings[ ‘oauth’ ], true );
}
}

}

When I called my handler, I got:

Type: Builder.DSLDependencyNotFoundException
Messages: The DSL Definition {REF={null}, REQUIRED={true}, ARGNAME={}, DSL={id:Socialite@Socialite}, JAVACAST={null}, NAME={socialite}, TYPE={any}, VALUE={null}, SCOPE={variables}} did not produce any resulting dependency The target requesting the dependency is: ‘handlers.Account’

Any idea?

Thank you.

Hi! There’s no component in modules/socialite/Models named Socialite. You want to inject “SocialiteManager@Socialite":

property name="Socialite" inject="SocialiteManager@Socialite";

Yes, it’s working. Thank you.
It is my first project using ColdBox modules.

Look that should be some change I should pull to the facebook login, I will update socialite module for coldbox and contentbox in next days. Let me know if something go wrong.

Awesome! A little more details on how to implement / use it would be helpful. A novice like me easily get lost. :slight_smile:

After logging in to Facebook, I was sent back to http://localdev/socialauth/provider/response/facebook?code=AQDLGKB_ztm3iKrdoGacXN… Where we should get user data?

Thanks!

Hvae you inserted your clientId/clientSecret in congig file?

Once you get the code from response simply call:

`
prc.user = socialite.with(rc.provider).user(rc.code);

`

Now your user insofrmation is stored in prc.user variable. You can then use it to login.

Yes, I have provided correct info. in ModuleConfig.cfc. I was redirected to Facebook for login; and then the page was redirected back to http://localdev/socialauth/provider/response/facebook?code=AQDLGKB_ztm3iK… and I only saw “facebook” text on the page.

I found the module has views/home/index.cfm, am I supposed to see that view?

Thanks!

Facebook has made some change to their api. I should upload the patch in next days. Could you try with google? It should work. If I remember the api of facebook is now 2.4 so you have to change in the code.

If it was me, I would be changing my client_id and secret id as quickly as you can. Putting that out in public is not a good idea.

Thanks Scott. I realized it after I posted; and I have reset it. :slight_smile:

sigh

Is there a comma between my first n last name!

Sorry, Andrew… I wasn’t sure where my brain was at that time. :wink:

lol, no biggie…

I’ve pushed new version. COuld you try? this fix facebook login.

I would suggest not to put your credentials in moduleconfig, but at application level. So you will avoid to change everytime you want to update module.

Simply create a struct like this in Coldbox.cfc

`

// Custom Settings
settings = {
oauth = {
facebook = {

},
google = {

},
github = {

},
linkedin = {

}
}
};

`

Hi Tropicalista,

The Facebook is working. Thank you so much for fixing/updating the module.
Yes, I think it’s better idea to put the creds. at application level.

Thanks again!

For those attempt to call Google using this Socialite module on Lucee 4.5, you might get error “Connection Failed”.
There is a fix for that by replacing three .jar files. See this link: [LDEV-429] Unable to access Youtube API using SSL - Lucee

Also, to make Socialite’s SES works, set setAutoReload(false); in routes.cfm. See this link: Google Groups

I hope that helps.