Skip to content

Migrate LinkedIn auth to official OAuth2 library#466

Merged
benadida merged 2 commits intomasterfrom
claude/linkedin-oauth2-migration-MmWTM
Jan 18, 2026
Merged

Migrate LinkedIn auth to official OAuth2 library#466
benadida merged 2 commits intomasterfrom
claude/linkedin-oauth2-migration-MmWTM

Conversation

@benadida
Copy link
Owner

  • Rewrite linkedin.py to use requests_oauthlib.OAuth2Session
  • Use LinkedIn's OpenID Connect userinfo endpoint for user data
  • Add CSRF protection with OAuth state parameter validation
  • Update settings to use LINKEDIN_CLIENT_ID and LINKEDIN_CLIENT_SECRET
  • Remove custom oauthclient directory (no longer needed)

The custom OAuth 1.0a client was used solely for LinkedIn. Now that LinkedIn supports OAuth 2.0, we can use the same pattern as GitHub and other OAuth2 providers.

- Rewrite linkedin.py to use requests_oauthlib.OAuth2Session
- Use LinkedIn's OpenID Connect userinfo endpoint for user data
- Add CSRF protection with OAuth state parameter validation
- Update settings to use LINKEDIN_CLIENT_ID and LINKEDIN_CLIENT_SECRET
- Remove custom oauthclient directory (no longer needed)

The custom OAuth 1.0a client was used solely for LinkedIn. Now that
LinkedIn supports OAuth 2.0, we can use the same pattern as GitHub
and other OAuth2 providers.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates LinkedIn authentication from a custom OAuth 1.0a implementation to OAuth 2.0 using the official requests_oauthlib library, bringing it in line with GitHub and GitLab authentication patterns.

Changes:

  • Rewrote linkedin.py to use OAuth2Session and LinkedIn's OpenID Connect userinfo endpoint
  • Added CSRF protection with OAuth state parameter validation
  • Updated configuration settings from LINKEDIN_API_KEY/LINKEDIN_API_SECRET to LINKEDIN_CLIENT_ID/LINKEDIN_CLIENT_SECRET
  • Removed the entire oauthclient directory containing custom OAuth 1.0a implementation

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
settings.py Updated LinkedIn configuration to use CLIENT_ID and CLIENT_SECRET naming convention, consistent with other OAuth2 providers
helios_auth/auth_systems/linkedin.py Complete rewrite to use OAuth2Session, implement CSRF protection, and use OpenID Connect userinfo endpoint
helios_auth/auth_systems/oauthclient/oauth/init.py Removed legacy OAuth 1.0a client library (522 lines)
helios_auth/auth_systems/oauthclient/oauth/rsa.py Removed RSA signature methods for OAuth 1.0a (120 lines)
helios_auth/auth_systems/oauthclient/oauth/CHANGES.txt Removed changelog for legacy OAuth library
helios_auth/auth_systems/oauthclient/client.py Removed custom OAuth client wrapper (147 lines)
helios_auth/auth_systems/oauthclient/README Removed documentation for legacy OAuth library

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +26
def get_oauth_session(redirect_url=None):
return OAuth2Session(
settings.LINKEDIN_CLIENT_ID,
redirect_uri=redirect_url,
scope='openid profile email',
)
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LinkedIn authentication system is missing from the OAuth integration tests. The existing tests in helios_auth/tests.py verify OAuth state validation and interface compliance for 'google', 'github', and 'gitlab', but 'linkedin' should be included in these test cases now that it also uses OAuth2.

Copilot uses AI. Check for mistakes.
Include LinkedIn in the existing OAuth test suite now that it uses
OAuth 2.0, testing:
- Required interface methods
- State verification for CSRF protection
- Returns None without authorization code
@benadida benadida merged commit 7d55b78 into master Jan 18, 2026
3 checks passed
@benadida benadida deleted the claude/linkedin-oauth2-migration-MmWTM branch January 18, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants