This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
class MeetupAccount(ProviderAccount):
pass
class MeetupProvider(OAuth2Provider):
id = "meetup"
name = "Meetup"
account_class = MeetupAccount
def extract_uid(self, data):
return str(data["id"])
def extract_common_fields(self, data):
return dict(email=data.get("email"), name=data.get("name"))
provider_classes = [MeetupProvider]

View File

@@ -0,0 +1,36 @@
from allauth.socialaccount.tests import OAuth2TestsMixin
from allauth.tests import MockedResponse, TestCase
from .provider import MeetupProvider
class MeetupTests(OAuth2TestsMixin, TestCase):
provider_id = MeetupProvider.id
def get_mocked_response(self):
return MockedResponse(
200,
"""
{"id": 1, "lang": "en_US", "city": "Bhubaneswar",
"photo": {
"thumb_link":"",
"photo_id": 240057062,
"highres_link":"",
"base_url": "http://photos2.meetupstatic.com",
"type": "member",
"name": "Abhishek Jaiswal", "other_services": {},
"country": "in", "topics": [{"name": "Open Source",
"urlkey": "opensource", "id": 563}, {"name": "Python", "urlkey":
"python", "id": 1064}, {"name": "Software Development", "urlkey":
"softwaredev", "id": 3833}, {"name": "Computer programming",
"urlkey": "computer-programming", "id": 48471},
{"name": "Python Web Development",
"urlkey": "python-web-development", "id": 917242},
{"name": "Data Science using Python",
"urlkey": "data-science-using-python", "id": 1481522}],
"lon": 85.83999633789062, "joined": 1411642310000,
"id": 173662372, "status": "active",
"link": "http://www.meetup.com/members/173662372",
"hometown": "Kolkata", "lat": 20.270000457763672,
"visited": 1488829924000, "self": {"common": {}}}}""",
)

View File

@@ -0,0 +1,6 @@
from allauth.socialaccount.providers.oauth2.urls import default_urlpatterns
from .provider import MeetupProvider
urlpatterns = default_urlpatterns(MeetupProvider)

View File

@@ -0,0 +1,25 @@
import requests
from allauth.socialaccount.providers.oauth2.views import (
OAuth2Adapter,
OAuth2CallbackView,
OAuth2LoginView,
)
from .provider import MeetupProvider
class MeetupOAuth2Adapter(OAuth2Adapter):
provider_id = MeetupProvider.id
access_token_url = "https://secure.meetup.com/oauth2/access"
authorize_url = "https://secure.meetup.com/oauth2/authorize"
profile_url = "https://api.meetup.com/2/member/self"
def complete_login(self, request, app, token, **kwargs):
resp = requests.get(self.profile_url, params={"access_token": token.token})
extra_data = resp.json()
return self.get_provider().sociallogin_from_response(request, extra_data)
oauth2_login = OAuth2LoginView.adapter_view(MeetupOAuth2Adapter)
oauth2_callback = OAuth2CallbackView.adapter_view(MeetupOAuth2Adapter)