Repository navigation
Conversation
Add the users.email scope to the Twitter OAuth request so we can access user email addresses. Update the profile API call to include the confirmed_email field and extract it from the user properties. Also add a test case to cover enrollment context when email data is present. This enables email retrieval as part of the Twitter OAuth authentication flow.
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR implements email retrieval support for the Twitter OAuth provider by adding the necessary scope, updating the API request to include email fields, and extracting the email from the response. The changes align with Twitter's OAuth 2.0 API v2 support for email address retrieval.
Changes:
- Added
users.emailscope to Twitter OAuth authorization requests - Updated profile URL to request the
confirmed_emailfield from Twitter's API - Modified email extraction logic to populate email from Twitter's response instead of hardcoding to None
- Added test coverage for both scenarios: users with and without confirmed email
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| authentik/sources/oauth/types/twitter.py | Added email scope to authorization, updated profile URL query parameters, and changed email extraction to use confirmed_email field |
| authentik/sources/oauth/tests/test_type_twitter.py | Added test data and test case for Twitter users with confirmed email |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Jens L. <[email protected]>
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20468 +/- ##
==========================================
- Coverage 93.28% 93.09% -0.19%
==========================================
Files 1045 1045
Lines 61348 61354 +6
Branches 424 424
==========================================
- Hits 57227 57118 -109
- Misses 4121 4236 +115
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This PR adds support for retrieving a user’s email address during the Twitter OAuth flow.
Fixes #18466
Test Plan
uv run coverage run manage.py test authentik.sources.oauth.tests.test_type_twitter --keepdbenvironment
confirmed email on Twitter
I can even update the test_enroll_context with the email field instead of creating a new test as per comments/preference