如何在 webpy 中使用 OpenID?

感谢 iRedmail 的 Bibby 分享。

---

I’m going to be trying to use OpenID as a universal login for a new webapp I’m working on. As luck would have it Web.py has a module just for this, and the API is super simple!  Now that I’ve got this working I’ve got to figure out how to actually integrate it into the app; this link looks helpful towards that.

   1. Install web.py:

sudo easy_install web.py
or
sudo apt-get install python-webpy

   2.

sudo easy_install python-openid
or
sudo apt-get install python-openid

   3. main.py:

import web, web.webopenid

urls = (
      r'/openid', 'web.webopenid.host',
      r'/', 'Index'
)

app = web.application(urls, globals())

class Index:
      def GET(self):
          body = '''
          Web.py OpenID Test

              %s

          ''' % (web.webopenid.form('/openid'))

          return body

      if __name__ == "__main__": app.run()

   4. Run

  python main.py

   5. Go to http://localhost:8080
   6. Voilà!

---

原文:http://log.liminastudio.com/programming/howto-use-openid-with-web-py

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。