Skip to content

Feat: Implement Google OAuth using django-allauth for user social authentication#2271

Open
pankaj-basnet wants to merge 3 commits intowger-project:masterfrom
pankaj-basnet:feat/allauth-oauth-social-login
Open

Feat: Implement Google OAuth using django-allauth for user social authentication#2271
pankaj-basnet wants to merge 3 commits intowger-project:masterfrom
pankaj-basnet:feat/allauth-oauth-social-login

Conversation

@pankaj-basnet
Copy link
Copy Markdown
Contributor

PR Description: This PR implements social authentication using the OAuth 2.0 framework via django-allauth, specifically configuring the Google provider.

Proposed Changes

  • Authentication Flow: Implements the OAuth 2.0 Authorization Code flow for secure user sign-in and account linking.

Related Issue(s)

Actions Performed:

  • Verified successful redirect to Google Account Selector.
  • Confirmed automatic user creation/login upon successful OAuth callback.
  • Validated that the setup_google_oauth command correctly populates the allauth's socialaccount_socialapp table.

@pankaj-basnet pankaj-basnet force-pushed the feat/allauth-oauth-social-login branch from f99bb27 to 32c0e69 Compare April 7, 2026 12:49
- Add dj-rest-auth to dependencies
- Register SocialLoginView for Google OAuth callback via REST
- Map dj-rest-auth URLs in wger/urls.py for mobile/headless auth
- Maintain compatibility with existing allauth template-based login
@pankaj-basnet
Copy link
Copy Markdown
Contributor Author

also made demo sample django+react project to show google oauth authentication. https://github.com/pankaj-basnet/Google-oauth-authentication---Django-and-React

@rolandgeider
Copy link
Copy Markdown
Member

rolandgeider commented Apr 9, 2026

there's some tests failing:

[1](https://github.com/wger-project/wger/actions/runs/24082190974/job/70245437796?pr=2271#step:8:10742)
  File "/home/runner/work/wger/wger/.venv/lib/python3.11/site-packages/allauth/socialaccount/adapter.py", line 212, in get_provider
    app = self.get_app(request, provider=provider, client_id=client_id)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/wger/wger/.venv/lib/python3.11/site-packages/allauth/socialaccount/adapter.py", line 302, in get_app
    raise SocialApp.DoesNotExist()
allauth.socialaccount.models.SocialApp.DoesNotExist

do we need to register them somehow first?

edit: nevermind, just saw in your other repo that we need to run manage.py setup_google_auth. Can you explain a bit how to get the YOUR_CLIENT_ID and YOUR_CLIENT_SECRET

@rolandgeider
Copy link
Copy Markdown
Member

something else, we should hide this behind a config option, so that this is not shown e.g. in local deployments where it's not used

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.

2 participants