Example #1
0
 def setUp(self):
     if 'allauth.socialaccount' in settings.INSTALLED_APPS:
         # Otherwise ImproperlyConfigured exceptions may occur
         SocialApp = get_social_app_model()
         sa = SocialApp.objects.create(name='testfb',
                                       provider='facebook')
         sa.sites.add(get_current_site())
Example #2
0
    def test_swap_in_new_social_app(self):
        SocialApp = get_social_app_model()
        app = SocialApp.objects.filter(provider=self.provider.id).first()

        username = str(random.randrange(1000, 10000000))
        email = '*****@*****.**' % username
        user = get_user_model().objects.create(
            username=username,
            is_active=True,
            email=email)
        account = SocialAccount.objects.create(
            user=user,
            app=app,
            provider=self.provider.id,
            uid='123')
        token = SocialToken.objects.create(
            app=app,
            token='abc',
            account=account)
        self.assertEquals(app.new_field, 'testing')
        self.assertEquals(token.app, app)

        ## Just to explicitly test that the swapped app is called
        from allauth.socialaccount.test_app.models import SocialAppSwapped
        self.assertTrue(isinstance(app, SocialAppSwapped))
Example #3
0
 def setUp(self):
     SocialApp = get_social_app_model()
     app = SocialApp.objects.create(provider='openid',
                                    name='openid',
                                    client_id='app123id',
                                    key='openid',
                                    secret='dummy')
     app.sites.add(get_current_site())
Example #4
0
 def setUp(self):
     SocialApp = get_social_app_model()
     app = SocialApp.objects.create(provider=self.provider.id,
                                    name=self.provider.id,
                                    client_id='app123id',
                                    key=self.provider.id,
                                    new_field="testing",
                                    secret='dummy')
     app.sites.add(get_current_site())
     app.save()
Example #5
0
from django.utils.crypto import get_random_string

from allauth.utils import import_callable
from allauth.account.models import EmailAddress
from allauth.socialaccount import providers
from allauth.socialaccount.providers.base import (ProviderAccount,
                                                  AuthProcess,
                                                  AuthAction)
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
from allauth.socialaccount.app_settings import QUERY_EMAIL
from allauth.socialaccount.models import get_social_app_model

from .locale import get_default_locale_callable


SocialApp = get_social_app_model()


GRAPH_API_VERSION = getattr(settings, 'SOCIALACCOUNT_PROVIDERS', {}).get(
    'facebook',  {}).get('VERSION', 'v2.4')
GRAPH_API_URL = 'https://graph.facebook.com/' + GRAPH_API_VERSION

NONCE_SESSION_KEY = 'allauth_facebook_nonce'
NONCE_LENGTH = 32


class FacebookAccount(ProviderAccount):
    def get_profile_url(self):
        return self.account.extra_data.get('link')

    def get_avatar_url(self):
Example #6
0
 def test_get_social_app_model(self):
     from allauth.socialaccount.test_app.models import SocialAppSwapped
     self.assertEqual(get_social_app_model(), SocialAppSwapped)