This article is part of the CakeDC Advent Calendar 2025 (December 6th 2025)
With the 9.1.0 version of CakeDC/auth plugin, a new social service has been added to be able to authenticate into your application using a Linkedin account.
This will be available with in the 13.x version of CakeDC/users for CakePHP 4.x application, and will be available for the the CakePHP 5.x versions soon.
Setting up a CakePHP 4 application
The fist step is to have a CakePHP application in any 4.x version.
If you dont have one already, follow the quick start guide from the documetation: https://book.cakephp.org/4/en/quickstart.html
Installing the CakeDC/users plugin with linkedin Oauth
We start by requiring the plugin depedencies:
composer require cakedc/users:^13.0 league/oauth2-linkedin:@stable firebase/php-jwt:@stable
Create the file "config/users.php" and add the following content:
<?php
use Cake\Routing\Router;
return [
'Users.Social.login' => true,
'OAuth.providers.linkedInOpenIDConnect' => [
'service' => \CakeDC\Auth\Social\Service\OpenIDConnectService::class,
'className' => \League\OAuth2\Client\Provider\LinkedIn::class,
'mapper' => \CakeDC\Auth\Social\Mapper\LinkedInOpenIDConnect::class,
'options' => [
'redirectUri' => Router::fullBaseUrl() . '/auth/linkedInOpenIDConnect',
'linkSocialUri' => Router::fullBaseUrl() . '/link-social/linkedInOpenIDConnect',
'callbackLinkSocialUri' => Router::fullBaseUrl() . '/callback-link-social/linkedInOpenIDConnect',
'defaultScopes' => ['email', 'openid', 'profile'],
// you can check your credentials in the "Auth" tab of your application dashboard in LinkedIn developers page
'clientId' => 'CLIENT_ID',
'clientSecret' => 'CLIENT_SECRET',
],
],
];
We can ignore the credentials for now.
Ensure the Users plugin is loaded in your "src/Application.php" file and load your custom users config file.
/**
* {@inheritdoc}
*/
public function bootstrap()
{
parent::bootstrap();
$this->addPlugin(\CakeDC\Users\Plugin::class);
Configure::write('Users.config', ['users']);
}
Run the plugin migrations to create the necesary tables.
bin/cake migrations migrate -p CakeDC/Users
In the routes file, update the root page to be the users profile from the plugin:
// config/routes.php
$builder->connect('/', ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'profile']);
You can create the first user, the super user by issuing the following command:
bin/cake users add_superuser
Now reload your application and try to login with the created user to make sure its working correctly.
Configuring the Linkedin Oauth service.
How to get a LinkedIn OAuth Client ID & Client Secret
- Go to LinkedIn Developer Portal: https://www.linkedin.com/developers/
- Click “Create app”
- Log in with your LinkedIn account.
- Fill in required details:
- App name
- Company / personal profile
- Logo (required – upload anything like a placeholder)
- Agree to the terms
- Click "Create app"
Once your app is created:
- Open your app dashboard
- Click the "Auth" tab
Here you will find:
- Client ID
- Client Secret (click “Show” to reveal)
Go the the file “config/users” and replace "CLIENT_ID" and "CLIENT_SECRET" with the respective values.
Configure OAuth 2.0 / OIDC Redirect URLs
In the "Auth" tab of the linkedin application, scroll to "OAuth 2.0 settings" and add the following redirect urls:
- https://{your-local-domain}/auth/linkedInOpenIDConnect
- https://{your-local-domain}/link-social/linkedInOpenIDConnect
- https://{your-local-domain}/callback-link-social/linkedInOpenIDConnect
Enable OpenID Connect (Very Important)
LinkedIn requires that you explicitly request the “OpenID” product.
- Navigate to: "Products" Tab → "Sign In with LinkedIn using OpenID Connect"
- Click "Request access".
Once approved, you can now request OIDC scopes: openid, email, profile.
Login in your application.
Everything should be ready now.
- In the login page of your applicaiton, click the link “Sign in with LinkedInOpenIDConnect”.
- Enter your login LinkedIn credentials.
- In the consent page, click “Allow”.
And Done! You should see your profile page and have your new user created.
This article is part of the CakeDC Advent Calendar 2025 (December 6th 2025)