Linkedin OAuth2 ๐ Guide
๐ Resources
๐ง LinkedIn OAuth2 App Setup Guide
Step 1: Create a LinkedIn Developer Account
Go to LinkedIn Developer Account.
Log in with your LinkedIn account or create one if you don't have it.
Step 2: Create a LinkedIn App
Click on Create App.
Fill in all basic details.
Associate your app with a company page (create one if you donโt have any).


Step 3: Verify the LinkedIn App
Request app verification via the Settings > Verify button.
Paste the verification link into a new browser window.
Press Verify.

Step 4: Client ID and Client Secret
Access Client ID and Secret from the Auth tab in the developer dashboard.
Go to the Products tab and request access to Sign In with LinkedIn using OpenID Connect and Share on LinkedIn.



๐จ Important: LinkedIn servers will only communicate with trusted URLs. Ensure your callback URL meets the following criteria:
Must be absolute:
https://example.com/auth/linkedin/callback
Parameters are ignored:
https://example.com/auth/linkedin/callback?id=1
becomeshttps://example.com/auth/linkedin/callback
Cannot include a
#
:https://example.com/auth/linkedin/callback#linkedin
is invalid.
Step 6: Store Credentials Securely
๐ Tip: Use a
.env
file for secure storage of credentials.
LINKEDIN_CLIENT_ID='๐ your-client-id'
LINKEDIN_CLIENT_SECRET='๐ your-client-secret'
LINKEDIN_REDIRECT_URI='๐ your-redirect-uri'
LINKEDIN_SCOPE=openid,profile,w_member_social,email
๐ Getting Started
Import LinkedIn Class and Configure Settings
from omni_authify.providers import LinkedIn
linkedin_provider = LinkedIn(
client_id='๐ your-linkedin-client-id',
client_secret='๐ your-linkedin-client-secret',
redirect_uri='๐ your-linkedin-redirect-uri',
scope='openid,profile,w_member_social,email'
)
Ensure your redirect_uri
matches the callback URL in both LinkedIn app settings and Django URLs.
๐ Methods
1. ๐ Get Authorization URL
Generates the login URL for LinkedIn authentication.
def get_authorization_url(state=None):
pass
Example:
auth_url = linkedin_provider.get_authorization_url(state='random_state_string')
2. ๐ Get Access Token
Exchanges the authorization code for an access token.
def get_access_token(code):
pass
Example:
access_token = linkedin_provider.get_access_token(code='authorization_code')
3. ๐ด๏ธ Get User Profile
Fetches the authenticated userโs profile data.
def get_user_profile(access_token):
pass
Example:
user_info = linkedin_provider.get_user_profile(access_token)
โ
Best Practices
๐ Secure Credentials: Use environment variables to protect sensitive data.
๐ Match Redirect URI: Ensure consistency between LinkedIn app settings and your application code.
โ ๏ธ Handle Errors Gracefully: Implement error handling for a smooth user experience.
๐ Final Result


Last updated
Was this helpful?