This quick patch automates the user registration and login method - moreover, it uses a different technique to authenticate. It visits linkedin login screen only once (by default, this module sends the user twice to the linkedin website).

Anonymous user clicks on linkedin button -> authenticates at linkedin.com -> automatically user gets created and logs him in.

Registered user clicks on linkedin button -> authenticates at linkedin.com -> the current drupal account gets connected with linkedin. Next time on-wards, he can login via linkedin.

Anonymous function was written/modified by my senior, bpadhu (http://drupal.org/user/619388) - I further modified it to add authenticated user functionality.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Hi Amrit, thanks for this. I'm currently using D7, would it be possible to do a patch for that version too? I would love to test that one.

amrit_b’s picture

Kline, is there any difference in the linkedin_access_token() {linkedin.inc file} between D6 and D7 version? I didn't get time to check. If they both are same, then you can try this patch in D7 - let me know how it goes.

dellicl’s picture

Hi!

I tried to apply this but I get error messages and cannot implement the patch to the module. This is just the thing I need for my site so I would really like this to work. I have patched modules before but this is the first time I get error-messages even though I think I am doing everything right.

Has anyone else tried this patch? Is it working?

amrit_b’s picture

you found the error while patching or inside drupal? which version are you using?

dellicl’s picture

While I was patching the latest dev-version of LinkedIn Integration module on my development site. When I try to run the patch I get this error:

Hunk #1 FAILED at 15.
Hunk #2 FAILED at 29.
Hunk #3 FAILED at 41.
Hunk #4 FAILED at 513.
4 out of 4 hunks FAILED -- saving rejects to file linkedin.module.rej

I am using Drupal 6.25 if that is any help. It would be really helpful if I could get this patch to work - because automated user creation while logging in with your LinkedIn account is just what I need!

amrit_b’s picture

FileSize
23.31 KB

Oh God! what have I done!! I am so sorry folks! I was in hurry and submitted a wrong patch. Applied on D7, but its a D6 patch :p

Here is the correct one. Please check and let me know if it works of not..

Thx
Amrit

dellicl’s picture

Hi!

I am having hard time understading your replies. Is this patch for version 6.x-1.x-dev like the title says or is this patch for D7 version of the module?

I am using D6 for my site and I would like to know if there is a way to automatically create user accounts when ppl use LinkedIn Integration module to sign-in to my site.

I also tried your new patch: it didn't work. I got over 20 Hunk-errors.

amrit_b’s picture

yeah this patch works well with the D6 version of linkedin module. How come are you getting errors? I tested it once again and its working for me.. These are the commands btw
,

git clone --recursive --branch master http://git.drupal.org/project/linkedin.git
cd linkedin/
git branch -a
git checkout 6.x-1.x
git status
git apply ../auto_login-1542130.patch
dellicl’s picture

Hey!

I managed to patch the 6.x-1.0-beta1 version of the linkedin integration module with your patch. First time I tried to log in a new user to my site with an LinkedIn account it worked great! After that I tried it again and it started to give me "Linkedin debug : 401 : No LinkedIn account is associated with this user" -error message (even though I still managed to log that user in to my site).

After that I decided to try the latest dev-version of LinkedIn integration and I tried to apply the patch to this version as well. This didnt go so well and while I tried to apply the patch I get this error message: "-bash: line 28: auto_login-1542130.patch: No such file or directory."

This is where the weird part comes in: when I deleted the dev-version of the LinkedIn Integration and replaced it with the beta1-version and tried to apply the patch again - it gives me the same error!

This is extremely weird. The commands and filenames etc. are correct and the path/filename is correct.

The command I am using for patching is the basic patch command: "patch -p1 < auto_login-1542130.patch" while being at the linkedin module folder. I have also tried other ways to apply the patch (full file path etc. in the command, but the outcome is always the same.)

amrit_b’s picture

I managed to patch the 6.x-1.0-beta1 version of the linkedin integration module with your patch. First time I tried to log in a new user to my site with an LinkedIn account it worked great! After that I tried it again and it started to give me "Linkedin debug : 401 : No LinkedIn account is associated with this user" -error message (even though I still managed to log that user in to my site).

Hmm.. Just disable linkedin debugging, it won't show the error :p and will work fine.

Regarding your patching issues, are you new to patching..? I personally put the patch file at sites/all/modules , so that the path becomes sites/all/modules/auto_login-1542130.patch - I do this because I don't need to download the patch again again I change the linked in module.. and after that I execute the shell commands I showed in #8

Its obvious that, when ever you delete / replace the linkedin module with a different version, the patch gets deleted (if you put the patch inside module/linkedin/ directory). This is the reason you get "........login-1542130.patch: No such file or directory"

BTW, do you work in a Finnish company? Coz even I work in a Finland based company :p

dellicl’s picture

Of cource the patch gets deleted. That is the reason why I have the patch donwloaded to my computer and I just put it back to the module folder after I have deleted and replaced the module with a different version.

About disabling the debugging... Yes I know that, but the problem is not only that simple, because even though your patch worked once - the second time I tried to log in using LinkedIn it directed me to the user account profile page where the module wanted to know do I want to link this account with this LinkedIn account. This is why I wanted to try the patch with the latest dev-version of the LinkedIn Integration because if the user automatically gets an user account after he logs in with LinkedIn account there should be no need for asking if the user wants to link his account with LinkedIn (cuz the user account is already created when he logged in via LinkedIn).

Because the way I understood this is that this patch should make the "Log in using LinkedIn"-function work like the "Log in using Twitter" where you log in using your Twitter-account and then your account is created - no need to verify if the accounts are linked afterwards.

nafmarcus’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Any chance of getting this patch for Drupal 7?

rami attallah’s picture

Hello Folks

I'm really lost here is this a patch for D7 or D6 ?

Cheers
Rami

Anonymous’s picture

D6, unfortunately. Also any idea what went into linkedin june 2nd update for D7 dev?

amrit_b’s picture

Hey I would love to port this to D7 - but not getting enough time... Let me see, if possible, will do it on this weekend.

Thx
Amrit

vyomkesh’s picture

Hi Amrit, any updates regarding porting it to D7?

Oceanman’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

Since the patch here is for D6 I changed the Version. It is otherwise very confusing.

mxwitkowski’s picture

Amrit, would be willing to help out on porting this patch to D7. I'm not much of a programmer, but willing to help out with testing, etc.

amrit_b’s picture

Allright, finally I got some timw to write the patch for D7. Haven't tested it though (hoping mxwitkowski will do some testing!)

Thx
Amrit

amrit_b’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
7.05 KB

Please use this one.. Its patched upon the 7.x-1.x-dev dated 02 June, 2012.

amrit_b’s picture

Status: Needs review » Active
mxwitkowski’s picture

amrit_b -- downloaded and applied the patch, all good so far. I will continue testing and report back any issues.

mxwitkowski’s picture

amrit_b -- completed some initial testing and attempted to login a new user with LinkedIn. Received the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, pass, mail, created, status, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 18 [:db_insert_placeholder_1] => $S$DMDxJnIGgodFTMTIoYO1Ud9XRbu54a.GFM1D9TksnDQ4eiuKTTTb [:db_insert_placeholder_2] => no_email@address.com [:db_insert_placeholder_3] => 1341544486 [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => a:3:{s:7:"contact";i:1;s:34:"user_relationships_ui_auto_approve";a:0:{}s:40:"user_relationships_allow_private_message";s:12:"on all users";} ) in drupal_write_record() (line 7013 of /Applications/MAMP/htdocs/includes/common.inc).

mxwitkowski’s picture

amrit_b -- second test was to allow a current site user to link to an existing LinkedIn account in the 'You must first authorize LinkedIn integration to use related features.' Looks like I was successful in associating the LinkedIn account with the Drupal account, but several errors were displayed during the process:

Notice: Undefined index: id in linkedin_profile_user_load() (line 117 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin_profile.module).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 14 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: is-current in include() (line 17 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: title in include() (line 18 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: company in include() (line 21 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: start-date in include() (line 28 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: end-date in include() (line 39 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).
Notice: Undefined index: summary in include() (line 52 of /htdocs/sites/all/modules/linkedin/linkedin_profile/linkedin-user-page-position-item.tpl.php).

mxwitkowski’s picture

amrit_b -- third test, I edited the LinedIn configuration page and changed LINKEDIN FIELDS on the USER PROFILE INTEGRATION section and after I unchecked all of the fields (saved the configuration) and then rechecked several items and saved again. After this, the errors mentioned in #24 have not been showing.

amrit_b’s picture

Hey thanks mxwitkowski. Will check on these errors again this weekend.

DrupalHiT’s picture

Hi,

Honestly, I'm working with Drupal for two weeks and I'm a little "confuse". I'm trying to understand what I have to do for an anonymous user can click on the login linedin Button for authentification (linkedin window open) then return in a new page on the website to fill a form that will be save in a MySql db, not in drupal.

So, the patch you are working on can it do the job ?

Regards

Michel

mxwitkowski’s picture

amrit_b, completed additional testing and narrowed the use case that triggers the error in comment #23:

  1. Use case #1: User is not currently logged into LinkedIn.com and then uses this module to log into their Drupal site with linkedin (and has never done so in the past) = all works well
  2. Use case #2: User successfully creates an account as outlined in use case #1, everything works well for subsequent logins to Drupal site regardless if they are logged into their linkedin.com account or not = good
  3. Use case #3: User is currently logged into Linkedin.com and then uses this module to log into their Drupal site with linkedin (and has never done so in the past) = receive the error noted in comment #23

Hopefully this info helps to narrow down the error and repair.

amrit_b’s picture

Thanks! Now it looks nice.

If you are logging into linkedin.com and closing the tab (without manually clicking on logout button) - keeps you logged in (in the cookies I guess). I assume you know this, but just in case ;)

Will check and reply with the new patch.

Thx
Amrit

mxwitkowski’s picture

amrit_b: I started comparing the D7 patch to the D6 patch and found some critical missing code in and around line 131 in the linkedin.inc file near the comment line
// Now we have linkedin access... Get the user information and create a user...

Also, I dug a bit deeper and saw that the code in the linkedin.inc file around the following comment is also missing in the D7 patch and is needed:
//Check if the same LinkedIn account is not already tied to another user

I am trying to adjust things on my end, but I am not much of a programmer and am introducing several other new errors in the process. . .

mxwitkowski’s picture

amrit_b, how are you making out with this patch? Ready to test as soon as it is posted.

rausku’s picture

I have played around a bit with the D6 patch.

I don't know if this is fixed in D7 patch, but what should happen when many users have the same name? For example - if a person with username John.Smith is already registered, and another one with the same name tries to register, how are they distinguished between? Using this patch I could access this existing account when I created a LinkedIn account named John Smith and registered in my Drupal site!

Also, it is safer to generate password with user_password function than to set it simply as 'password'.
-

Overall, this method of registration seems quite problematic, as it's currently not possible to retrieve the user's email address from LinkedIn. Email addresses are individual, so they are great for user names when generating them automatically, but LinkedIn doesn't offer them through their API for whatever reason.

I think there should be a step in the registration process which asks for the user's e-mail and after that generates the user, unless LinkedIn changes their policies.

nafmarcus’s picture

That's exactly what I do, i.e. ask for an email address.
But LinkedIn just released a new authentication method that will ask the user for their email address and presumably pass it back to the requesting application.
They just sent mail yesterday.

amrit_b’s picture

@nafmarcus can you post the API link please?

@mxwitkowski Hey man how are you doing? First, thanks a lot! I truly appreciate. I am so sorry for not giving time to this. Have been extremely busy for last few days. I saw that you have written so many patches yourself, so why don't you give a try. Its really easy. You can ask me quick questions via email anytime.. I have this sat and sun days free. Let me see if I can do something on this or not.

Thx
Amrit

nafmarcus’s picture

Here's what I received from LinkedIn

Email Address Request Added to Sign In with LinkedIn
Now request email addresses from your users who sign in with their LinkedIn credentials via the Sign In with LinkedIn plugin. This makes it easy for you reach a valuable professional audience directly — and keep them engaged.

And if you go to this page, https://developer.linkedin.com/documents/authentication, you'll see that they now request permission to release the users email.

danteblitz’s picture

Has anyone been able to allow user registration via linkedIn now that linkedIn allow email permissions?

Cromian’s picture

I kind of got confused as I went over this thread. Has anyone been able to successful accomplish this? And would someone be kind enough to share there "linkedin.inc" file with the patched up code? I'm not much a coder when it comes to Drupal. More of a theme/site designer when it comes down to things.

And does anyone know of a program that automatically adds Drupal patches to the existing code?

Thanks!
- C

tamerzg’s picture

Status: Active » Needs review
FileSize
8.68 KB

I took patch from #20 and fixed the error mentioned in #23. Also I added permission for email and now when users log in through Linkedin we will save their Linkedin email address.
Patch is attached and for those who don't want to bother with applying the patch can take the working modified version of this module at http://www.zoubi.me/blog/drupal-7-linkedin-login-module

ckng’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Assigned: amrit_b » Unassigned
FileSize
2.86 KB

Attached is a simplified patch of above patches for D6, D7 should trivial with update to db calls. Added hook_linkedin_user_save($account, $liuser) so other modules can make changes to user, e.g. content profile.

However, IMO the module should be rewrote to be cleaner instead of one big linkedin_access_token() function.

To Do:
- make it as an option to create user

ramazanaman’s picture

I kind of got confused as I went over this thread.

ckng’s picture

Tested patches #20, #38, both not working for me (after backport to D6). Hence I created a working copy #39.

TimoSpijkerboer’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Thx ckng. I have installed your version #39. However, I still suffer the duplicate entry error in the following case:
Someone logins using LinkedIn who's profile has not yet been linked. Hence, a new user is created. However, if the email address already exists, a duplicate entry error appears.

finmccarthy’s picture

Hi @Tamerzg

I have downloaded the patched module in #38 from zoubi.me and set it up. Just wondering, for a first time user it creates the account fine but doesn't actually log the user in. ie if i use a new account and click on log in with linked in, the account is created and the page is redirected to the new user account page eg /user/3 but the page shows permission denied - if i again click on login with linkedin it works great on all subsequent visits.

Is there some way to get around this in your knowledge?

Thanks

Fin

finmccarthy’s picture

Took a while to get my head around this - but here is the answer I came up with

There is actually no call to login right after a new user is created from linkedin, to correct this add the following 2 lines at line 153 in the patched linkedin.inc file

      $registered = user_load($account->uid);
      $user = $registered;
andykisaragi’s picture

In case anyone else wants it, here's a D7 version of patch in #39.

finmccarthy’s picture

To anyone using the patches on this thread - please be aware that most of the patches are creating a user with a plaintext password of "password"

'pass' => 'password',

This is obviously a security issue

FYI

sarfraz742’s picture

Priority: Normal » Critical

I am running the dev version for Drupal 7.x. I have a valid API key and secret code for LinkedIn. I've added this to the LinkedIn configuration in my site.

I click on the LinkedIn link in my site login page to Go to LinkedIn to make the connection. After putting User Name and password It redirects me immediately to my site login page with out login into my drupal site.

When i again follow the same above mentioned process than i log in into my drupal site, but i am unable to get my linked in profile info in my custom module through $account variable. I need that linked in profile info in $account array.

Any answer will be appreciate.

Thanks

nafmarcus’s picture

#46: I would call that an understatement, having everyone on the site with an identical, obvious password. I spent a panic-ed Saturday night fixing this. Wish I had realized it sooner.

nozies’s picture

I added some basic validation before inserting new account, ie. when user unlink account and tries to log in again with the LinkedIn or user with same name/email already exists.

visabhishek’s picture

Priority: Critical » Normal
FileSize
6.71 KB

#49 is working fine for me.
i added a user mail with message which contains the random generated password.
For password , you must create a password token on the basis of http://drupal.org/node/1165126, and add in user mail template.

allabakash.g’s picture

Issue summary: View changes
FileSize
626 bytes

#50
After Applying this Patch mail_password_after_adding_new_user-1542130.patch.
I am able to create a user account, but not able to log in the first time.
So I have modified the code in "LinkedIn.inc"
Now it creates a user as well as logged in,
please review

phponwebsites’s picture

I used above 4 patches. But still i can't login using linkedin.

le72’s picture

phponwebsites, if you are on non https site, you will never able to connect. Try to enable debug of LinkedIn Integration module.
For requests from non secure sites (non https) set CURLOPT_SSL_VERIFYPEER to 0
in _linkedin_http_request() function around line 340 of linkedin.inc file

wweibel’s picture

I downloaded the entire project as posted by @Tamerzg #38, but it was still not working. A few errors being thrown and the user still not being logged in. This patch is against the current 7.x-1.x branch and also fixes the password issue addressed in #32 and # 46. The email address assigned to the created user is the LinkedIn account email.

The user will also be returned to the same page they were on after logging in, ie. the login block is being used on multiple pages, and re: login block - removed the built-in theme, css, and js, making the LinkedIn login a HTML button and below the standard login form buttons.

oss-usa.com’s picture

astenman’s picture

Hello,

I am interested in this as well. I applied the patch in #54. It seems to work, but I get a warning when I log in

Notice: Undefined index: op in linkedin_auth_form_alter() (line 57 of /var/www/clients/client43/web126/web/drupal/sites/all/modules/linkedin/linkedin_auth/linkedin_auth.module).

Kind regards,
/Anders

matthewmessmer’s picture

I was unable to get patch #54 or #50 to work without errors. Some of the errors seemed to do with the work done on #54 to change the markup of the login link.
#49 was working, but I noticed that if the linkedin token was expired or revoked, the linkedin login would fail ungracefully. I tweaked the patch so that if the token is revoked, the user is prompted again to agree to login with linkedin if their uid is still attached to the linkedin id in the authmap table. If the authmap table doesn't have their linkedin id, a new user is created as normal.

I took a queue from #54 and made it so that the username is set to the email address to avoid any issue with duplicate usernames (usernames like "Joe Smith35" that #49 was creating). When trying to create a new user, it still checks if the email is already in use by another user either in their username or email field and shows an error if it is already in use prompting the user to login using their drupal username and password and then connect to linkedin in their user settings in order to avoid duplicate accounts.

This new patch should apply cleanly to the base 7.x-1.x-dev version.

matthewmessmer’s picture

Some of the code that had been copied from patch #50 and #49 was causing existing drupal accounts to not be able to be linked to LinkedIn. This new patch should fix this problem.

Dom.’s picture

Patch#58 looks good, but just did not applied smoothly.
Here it is repacked with module folder as base. Applies on 7.x-1.x branch.

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

#59 worked for me, thanks!

Minor notes:

  • I changed scope=r_fullprofile+r_emailaddress+r_contactinfo to just scope=r_basicprofile+r_emailaddress since my application is not registered with linkedin and full profile is not available.
  • The call to _linkedin_profile_vget_user_page_linkedin_fields() requires linkedin_profile to be enabled. Could we skip this? Or add a drupal_load('module', 'linkedin_profile'); to bring that function into scope.
TuWebO’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.86 KB
928 bytes

Hello,
It worked for me too, thanks!

The only issue I've found is that the linkedin scope is hardcoded and there is no way to alter it.

I've added a drupal_alter() so other modules can change the scope and maybe set some other variables (like $_SESSION).

Do you think it is a good idea?

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

@TuWebO thats a great improvement! Using a drupal_alter() allows users to change the scope whenever they need and doesn't require an admin interface.

TuWebO’s picture

Hi @kscheirer thanks for the review!
I'm already using the patch in a development site, and it looks good.

TuWebO’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.99 KB
497 bytes

Hi,
do you think it will be good also to have a hook_linkedin_user_presave()?

This way we can control the flow right before the user is saved.

In my case is useful to see if the user is registering (with some parameters) or login in. This way I can modify the flow based on some parameters, and even do not create the user account under some circumstances.

Patch attached.

ArTii94’s picture

@TuWebO can You post whole working module for 7.x.1.x branch? Because when I'm applying patches most of them are getting rejected, don't know why... I got errors from installing #38 module.

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

@ArTii94 - the patch in #38 is from 5 years ago, its not surprising it doesn't apply. Have you tried the latest patch in #64? You should be able to apply that directly.

@TuWebO - looks good!

Once this gets in, maybe it's time for a 1.0 release?

kscheirer’s picture

sarfraz742’s picture

@TuWebO and @kscheirer #64 i tried for my fresh drupal 7 setup site but following line of code in your patch throwing error
$scope = array('r_fullprofile', 'r_emailaddress', 'r_contactinfo');

But when i replace it this line of code with following code

$scope = array('r_basicprofile', 'r_emailaddress');

Then its working good.

Can some one guide me where i am doing any mistake?

Thanks