标签: django-allauth

如何在api上给定访问令牌时创建新用户和新的django allauth社交帐户?

我有一个移动应用程序,允许用户通过Facebook注册.从FB收到访问令牌后,我将其发送到Django后端.

但那又怎样?

django-allauth里面有一个方法,我可以提供访问令牌,让它创建新的用户/社交帐户吗?

或者我需要手动完成所有操作吗?

django facebook tastypie django-allauth

7
推荐指数
1
解决办法
2886
查看次数

用django allauth连接facebook phonegap登录

我正在建立一个应用程序,允许用户注册/登录Facebook,然后他应该能够登录(总是通过Facebook)到"主"网站

说实话,这比这复杂一点.那是因为我在主网站上使用django-tastypiedjango-allauth来允许注册,登录和浏览我们的API

基本上我想让移动应用程序用户浏览tastypie API(只有在登录时才可访问,如果您是主网站中的用户)并授予他添加行的权限(如订单)

这就是我所拥有的

  • 一个带有Facebook登录功能的phonegap应用程序(我现在正在努力)
  • 使用django-allauth和django-tastypie的网站,让我使用allauth的Facebook登录注册为新用户
  • 如果移动用户通过Facebook进行注册,主网站上没有任何痕迹(这是问题)

我基本上很困惑我应该如何使用访问令牌以及如何传递更多参数(我不需要Facebook信息来完成注册,但也有一些自定义字段)

任何人都有这方面的经验或想揭露他的工作流程?

django facebook tastypie cordova django-allauth

7
推荐指数
1
解决办法
2767
查看次数

django-allauth:如何为我的域名添加网站?

我是Django的新手,我已经安装了django-allauth.

我按照文档进行操作,但是我坚持使用安装后的步骤:

  1. 为您的域添加网站,匹配settings.SITE_ID(django.contrib.sites app).

  2. 对于每个基于OAuth的提供商,请添加社交应用(socialaccount应用).

  3. 填写从提供商处获得的站点和OAuth应用凭据.

我根本不明白这一部分.

我试图注册该网站&socialaccount但没有任何变化.另外,我看到我必须定义站点ID,所以我把它放在我的设置中:

SITE_ID = '1'
Run Code Online (Sandbox Code Playgroud)

拜托,有人可以帮帮我吗?任何帮助将不胜感激.

UPDATE

我找到了一个教程,让我继续这个.我在Facebook注册了一个应用程序,我获得了一个APP ID和秘密,我建立了/ admin/socialaccount/socialapp /但即使一切准备就绪我得到了

      Page not found (404)
Request Method: GET
Request URL:    MyIP/accounts/profile/
Using the URLconf defined in gameproject.urls, Django tried these URL patterns, in this order:
^admin/
^accounts/ ^ ^signup/$ [name='account_signup']
^accounts/ ^ ^login/$ [name='account_login']
^accounts/ ^ ^logout/$ [name='account_logout']
^accounts/ ^ ^password/change/$ [name='account_change_password']
^accounts/ ^ ^password/set/$ [name='account_set_password']
^accounts/ ^ ^inactive/$ [name='account_inactive']
^accounts/ ^ ^email/$ [name='account_email']
^accounts/ ^ ^confirm-email/$ [name='account_email_verification_sent']
^accounts/ ^ ^confirm-email/(?P<key>\w+)/$ [name='account_confirm_email']
^accounts/ ^ …
Run Code Online (Sandbox Code Playgroud)

django django-authentication django-allauth

7
推荐指数
2
解决办法
2204
查看次数

Django-Allauth中的自定义表单验证

我想对django-allauth中的字段进行一些额外的验证.例如,我想阻止使用免费电子邮件地址.所以我想在注册时运行这个方法

def clean_email(self):
    email_domain = self.cleaned_data['email'].split('@')[1]
    if email_domain in self.bad_domains:
        raise forms.ValidationError(_("Registration using free email addresses is prohibited. Please supply a different email address."))
Run Code Online (Sandbox Code Playgroud)

同样,我想在电子邮件地址以外的其他字段上运行自定义验证.我怎么能这样做?

django-allauth

7
推荐指数
1
解决办法
1450
查看次数

关系"account_emailaddress"不存在 - django错误

我正在按照本教程将社交媒体登录集成到我的django项目中 -

http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/

但是在完成所有步骤后,当我尝试使用facebook登录时,我收到此错误

relation "account_emailaddress" does not exist
Run Code Online (Sandbox Code Playgroud)

我不明白出现了什么问题,因为所有数据库修改都正常运行而没有错误.

提前感谢您的宝贵答案.

堆栈跟踪

Environment:


Request Method: POST
Request URL: example.com/accounts/facebook/login/token/

Django Version: 1.6.6
Python Version: 2.7.4
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.contrib.admin',
 'django.contrib.comments',
 'south',
 'registration',
 'endless_pagination',
 'links',
 'south',
 'debug_toolbar',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.facebook')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/providers/facebook/views.py" in login_by_token
  76.                     ret = complete_social_login(request, login)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in complete_social_login
  119. …
Run Code Online (Sandbox Code Playgroud)

python django facebook django-allauth

7
推荐指数
2
解决办法
6731
查看次数

在/ rest-auth/registration/account-confirm-email上配置不正确

我正在使用django-rest-auth进行用户注册并验证电子邮件.我可以在用户注册时成功发送电子邮件.但是,对于电子邮件验证,我收到以下回溯的错误:

File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in get
  155.         return self.render_to_response(context)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in render_to_response
  130.             template=self.get_template_names(),
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in get_template_names
  142.                 "TemplateResponseMixin requires either a definition of "

Exception Type: ImproperlyConfigured at /rest-auth/registration/account-confirm-email/vjohhnrf6xpkmn1jxbzaopdn0g79tdyofumeeuyuehcuja8slyz7nzq1idyifcqk/
Exception Value: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
Run Code Online (Sandbox Code Playgroud)

有关如何解决此问题的任何想法?

python django django-allauth django-rest-auth

7
推荐指数
2
解决办法
3054
查看次数

ImportError:无法导入名称RemovedInDjango19Warning

我在Django 1.8.7上,我刚刚安装了Django-Allauth,通过克隆repo并在我的webapp终端上的应用程序目录中运行pip install.现在当我运行manage.py migrate时,我收到此错误:

?src git:(master) ? python manage.py migrate
    Traceback (most recent call last):
      File "manage.py", line 8, in <module>
        from django.core.management import execute_from_command_line
      File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
        from django.apps import apps
      File "/Library/Python/2.7/site-packages/django/apps/__init__.py", line 1, in <module>
        from .config import AppConfig
      File "/Library/Python/2.7/site-packages/django/apps/config.py", line 6, in <module>
        from django.utils.module_loading import module_has_submodule
      File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 4, in <module>
        from importlib import import_module
      File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 6, in <module>
        from django.utils.deprecation import RemovedInDjango19Warning
    ImportError: cannot import name RemovedInDjango19Warning …
Run Code Online (Sandbox Code Playgroud)

python django django-models python-2.7 django-allauth

7
推荐指数
1
解决办法
9279
查看次数

Django allauth注册没有密码

是否可以使用电子邮件作为用户名创建用户帐户,而没有其他详细信息,例如使用allauth的密码?目的是使注册过程尽可能简单.注册时可以跳过密码并在电子邮件确认时更新吗?我在python shell(./manage.py shell)中尝试了这个场景并且有成功的输出.

In [1]: from django.contrib.auth.models import User

In [2]: User.objects.create(username='nopass')
Out[2]: <User: nopass>

In [3]: User.objects.all()
Out[3]: [<User: userone>, <User: nopass>] 
In [4]: usr=User.objects.all()[1]
In [5]: usr.set_password('pwdnotset')
In [6]: usr.save()
In [7]: from django.contrib.auth import authenticate
In [8]: authenticate(username='nopass',password='pwdnotset')
Out[8]: <User: nopass>
Run Code Online (Sandbox Code Playgroud)

我已经提到过这个链接,发现当时没有这样的设置.然而,回复是在2013年发布的.如果设计了一种在注册时使用某些allauth配置创建没有密码的用户的方法,将会很有帮助.提前致谢.

python passwords django user-accounts django-allauth

7
推荐指数
1
解决办法
991
查看次数

结合序列化器和模型功能

我有两个序列化器... MyRegisterSerializer继承并扩展了流行的应用程序/程序包django-rest-auth,该程序/程序包连接到相当标准的用户表。我还为定制应用程序TeamSerializer(与用户一对多关系)提供了模型和序列化器。当用户注册时,我希望他们能够同时加入一个团队,因此我需要以某种方式创建一个团队,返回团队ID,然后将该ID传递给RegisterSerializer,以便团队可以存储在用户表中。我知道我可以打两次电话,首先创建团队并返回值,然后将其传递给寄存器序列化器,但是有没有办法在一个序列化器中完成所有这些工作?我是python的n00b使用者,考虑到我必须按get_cleaned_data()原样返回函数,因此找不到很好的示例。谢谢!

class TeamSerializer(serializers.ModelSerializer):

  class Meta:
    model = Team
    fields = ('id', 'name', 'logo', 'user')

class MyRegisterSerializer(RegisterSerializer):
  first_name = serializers.CharField()
  last_name = serializers.CharField()

  def get_cleaned_data(self):
    super(MyRegisterSerializer, self).get_cleaned_data()
    return {
        'team_id': <How do I get this value>
        'username': self.validated_data.get('username', ''),
        'position': self.validated_data.get('password1', ''),
        'email': self.validated_data.get('email', ''),
        'first_name': self.validated_data.get('first_name', ''),
        'last_name': self.validated_data.get('last_name', '')
    }
Run Code Online (Sandbox Code Playgroud)

python django serializer django-allauth django-rest-auth

7
推荐指数
1
解决办法
151
查看次数

无法使用 dj-rest-auth + django-allauth 登录 Salesforce

我的应用程序有一个 Django 3.1 后端,带有django-allauthdj-rest-auth(积极支持django-rest-auth 的分支)。

我的移动和 Web 前端已经可以通过 REST 使用 Facebook 和 Google 登录。我现在正在尝试将 Salesforce 添加为第 3 种 REST 社交登录方法,但遇到了问题。

我已按照Salesforcedjango-allauth 说明进行操作

  • 使用 id 和 openid 范围(以及其他一些范围)创建了一个 Salesforce Connected App,并将回调 URL 设置为 https://www.mywebdomain.com/accounts/salesforce/login/callback/
  • 在 Django 中创建了一个 SocialApplication,在“Key”字段中使用客户端 ID、密码和登录 URL ( https://login.salesforce.com/ )
  • 在 INSTALLED_APPS 中包含 allauth.socialaccount.providers.salesforce

我一直在使用客户端JSforce在前端启动 Salesforce 身份验证请求,但如果其他方法更简单/更好/等,我愿意接受其他方法。

jsforce.browser.login()在我客户的 JS 代码中运行会打开 Salesforce 登录弹出窗口。输入 Salesforce 登录凭据后,Salesforce 系统重定向到我定义的回调 URL,从而生成一个显示以下文本的页面:

社交网络登录失败
尝试通过您的社交网络帐户登录时发生错误。

该页面地址栏中的 URL 如下所示:

https://www.mywebdomain.com/accounts/salesforce/login/callback/#access_token=00D3t000004QWRm%21ARwAQPfHWiM6jdB43dlyW6qjEw._34mjzGi_Jv6YCXp0QssT.9F9lCge5_YaH8gqTy3Od6SywCs8X9zOGv145SyviBVeGdn0&instance_url=https%3A%2F%2Fna123.salesforce.com&id=https%3A%2F%2Flogin.salesforce.com%2Fid%2F00D3t000004QWRmEAO%2F0053t000008QBetAAG&issued_at=1606802917608&signature=KvxAX0WBCFQYY%2BO25id9%2FXxpbh2q2d2vWdQ%2FFV5FCBw%3D&state=jsforce0.popup.c0ockgct29g&scope=id+api+web+refresh_token+openid&token_type=Bearer
Run Code Online (Sandbox Code Playgroud)

我试图调试,并在我的后台打印错误,但两者auth_error.code并 …

django salesforce django-allauth django-rest-auth jsforce

7
推荐指数
1
解决办法
213
查看次数