Skip to content
Linkedin login
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
README.md
composer.json

README.md

Instalation

The best way is via Composer:

composer require fabian/linkedin-nette:dev-master

Usage

linkedin:
    appId: "YOUR_API_KEY"
    appSecret: "YOUR_API_SECRET"
    permissions: [r_fullprofile, r_emailaddress]

and extension:

extensions:
    linkedin: \Fabian\Linkedin\LinkedinExtension
  • in your BasePresenter inject LinkedIn extension:
/**
 * @var \Fabian\Linkedin\Linkedin
 */
private $linkedin;

public function __construct(\Fabian\Linkedin\Linkedin $linkedin)
{
    parent::__construct();
    $this->linkedin = $linkedin;
}
  • and create component handling login operations:
protected function createComponentLinkedinLogin()
{
    $dialog = $this->linkedin->createDialog();
    /** @var \Fabian\Linkedin\LoginDialog $dialog */
    
    $dialog->onResponse[] = function(\Fabian\Linkedin\LoginDialog $dialog) {
        $me = $this->linkedin->call(
            'people/~:(id,first-name,last-name,email-address)'
        );
        
        // if user is not found in your database, register new based on LinkedIn profile details
        if (!$existing = $this->usersModel->findByLinkedinId($me->id)) {
            $existing = $this->usersModel->registerFromLinkedin((array) $me);
        }

        $this->user->login(new \Nette\Security\Identity($existing->users_id, $existing->role, $existing));
    };
    
    return $dialog;
}
  • place LinkedIn login in your template:
<a n:href="linkedinLogin-open!">Login by LinkedIn</a>

Inspired by Kdyby\Facebook

You can’t perform that action at this time.