简体   繁体   English

我在django应用中的哪里对dwolla的用户进行身份验证?

[英]Where in my django app do I authenticate my users for dwolla?

I've never really worked with APIs, JSON, or OAUTH, and I'm trying to use Dwolla for payments in my website. 我从未真正使用过API,JSON或OAUTH,并且正在尝试使用Dwolla在我的网站上付款。 Since I've never seen the process of authenticating users with oauth, I'm having a hard time trying to figure out what I need to put and especially where I need to put it. 由于我从未见过使用oauth对用户进行身份验证的过程,因此,我很难尝试弄清楚需要放置的内容,尤其是在放置位置。 The documentation available for dwolla doesn't make much sense for me. dwolla可用的文档对我而言意义不大。 I even did the codecademy.com lessons pretty easily and still have no idea where to begin when trying to use it in my django project. 我什至很轻松地上了codecademy.com课程,并且仍然不知道在django项目中尝试使用它的起点。 I use django-registration to allow users to register on my website, so am I supposed to authenticate users with oauth when they register for my site so that they are assigned an oauth token? 我使用django-registration来允许用户在我的网站上注册,因此我应该在用户注册我的网站时使用oauth对用户进行身份验证,以便为他们分配oauth令牌吗? Do I send a user to the auth url with a link within my templates, or with code in a view? 是否通过模板中的链接或视图中的代码将用户发送到身份验证URL? Do I need to create a new model with a Foreign Key field to associate it with my users? 我是否需要使用外键字段创建新模型以将其与我的用户相关联? I'm really at a loss as to what this process should look like and how exactly Dwolla's API is interacting with my django app. 对于这个过程应该是什么样子以及Dwolla的API与django应用程序交互的方式,我确实感到茫然。 This is the documentation from dwolla for python, and this is the documentation for oauth with dwolla. 是dwolla的python文档, 是dwolla的oauth的文档。 I even tried reading this oauth guide to get an idea of what's going on. 我什至尝试阅读此oauth指南以了解发生的情况。 The oauth2 overview on github gives an example for using twitter's API, but that left me more confused becasue it is specific to twitter's API. github上oauth2概述提供了使用twitter的API的示例,但由于它特定于twitter的API,这让我感到更加困惑。 Also, do I need to install anything other than oauth2 and dwolla? 另外,我是否需要安装oauth2和dwolla以外的任何东西? I know all the pieces are there, I just am having a very hard time understanding how they fit together. 我知道所有零件都在那里,我只是很难理解它们如何组合在一起。 Can anyone clarify the steps I need to take, or at least does anyone have a good tutorial for an absolute beginner to oauth and APIs? 谁能阐明我需要采取的步骤,或者至少有人为oauth和API的初学者提供了很好的教程? Thanks in advance for any help. 在此先感谢您的帮助。

You can authenticate a user anywhere in your Django app that is convenient for you. 您可以在您方便的Django应用中的任何地方对用户进行身份验证。 A good place is on a page where the user may be editing their account details. 一个好的地方是用户可以在其中编辑其帐户详细信息的页面上。

In order to actually write the code, you can put away any oAuth documentation from Twitter or wherever. 为了实际编写代码,您可以收起Twitter或任何地方的所有oAuth文档。 oAuth isn't a code base like jQuery that you need to learn how to use. oAuth不是像jQuery这样的代码库,您需要学习如何使用它。 Its just set of guidelines as to how developers could allow their users' accounts talk to their accounts on other sites and trust that its the same user. 它只是关于开发人员如何允许其用户帐户与其他站点上的帐户进行对话并信任其相同用户的一组准则。

The core idea is that site #1 (in this case, Dwolla) gives site #2 (your site) a token , often some encrypted string of text, eg, !432d8dk*dfas&&3, that can be used to more or less log in the user to site #1 while they are on site #2. 核心思想是站点1(在本例中为Dwolla)为站点2(您的站点)提供token ,通常是一些加密的文本字符串,例如!432d8dk * dfas && 3,可用于或多或少地登录用户在站点#2上的同时访问站点#1。 More accurately, the token gives permissions that the user agrees to during the site #1 log in for site #2 to access parts of their site #1 account. 更准确地说,令牌授予用户在站点1登录期间同意的权限,以使站点2可以访问其站点1帐户的一部分。

Here's a checklist of things to do to wire up the authentication of each user on your site with their account on Dwolla's site. 这是一份检查清单,可用来连接网站上每个用户的身份验证以及Dwolla网站上的帐户。 This is based on Dwolla's python API posted on Github . 这基于在Github上发布的Dwolla的python API Note this is for a Flask and not a Django app. 请注意,这是针对Flask而非Django应用。

  1. Register your app with Dwolla so you can get your public and private key (listed as _keys.apiKey, _keys.apiSecret on Dwolla's oAuth example ) 在Dwolla中注册您的应用,以便获得您的公钥和私钥( 在Dwolla的oAuth示例中列为_keys.apiKey, _keys.apiSecret
  2. Indicate the redirect URL, oauth_return_url which is where Dwolla will redirect the user when they are done logging in on Dwolla. 指示重定向URL oauth_return_url ,这是Dwolla在用户完成在Dwolla上的登录后将对其进行重定向的位置。
  3. (optional, but likely a good idea so the user only has to go through the oAuth/login on Dwolla's site once) store the token , which is specific for the user that logged in on Dwolla's site, in your database. (可选,但可能是一个好主意,因此用户只需在Dwolla的站点上进行一次oAuth /登录)就可以将token (特定于登录Dwolla的用户)存储在数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM