本文整理汇总了Python中openid.consumer.discover.OpenIDServiceEndpoint.fromXRDS方法的典型用法代码示例。如果您正苦于以下问题:Python OpenIDServiceEndpoint.fromXRDS方法的具体用法?Python OpenIDServiceEndpoint.fromXRDS怎么用?Python OpenIDServiceEndpoint.fromXRDS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openid.consumer.discover.OpenIDServiceEndpoint
的用法示例。
在下文中一共展示了OpenIDServiceEndpoint.fromXRDS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: openid2_get_redirect
# 需要导入模块: from openid.consumer.discover import OpenIDServiceEndpoint [as 别名]
# 或者: from openid.consumer.discover.OpenIDServiceEndpoint import fromXRDS [as 别名]
def openid2_get_redirect(request, provider, callback, scope, mode):
xrds = urllib.urlopen(providers[provider]["xrds"])
if xrds.getcode() != 200:
raise Exception("OpenID Failed: Invalid response from " + providers[provider]["displayname"] + " on obtaining a XRDS information: " + xrds.read())
xrds = xrds.read()
from openid.consumer.consumer import Consumer
from openid.consumer.discover import OpenIDServiceEndpoint
from openid.store.memstore import MemoryStore
service = OpenIDServiceEndpoint.fromXRDS(providers[provider]["xrds"], xrds)[0]
consumer = Consumer(request.session, MemoryStore())
auth = consumer.beginWithoutDiscovery(service)
if "extensions" in providers[provider]:
for ext, d in providers[provider]["extensions"].iteritems():
for k, v in d.iteritems():
auth.addExtensionArg(ext, k, v)
if mode == "compact": # works with Google
auth.addExtensionArg("http://specs.openid.net/extensions/ui/1.0", "mode", "popup")
return auth.redirectURL(realm=SITE_ROOT_URL, return_to=callback)
示例2: create_service
# 需要导入模块: from openid.consumer.discover import OpenIDServiceEndpoint [as 别名]
# 或者: from openid.consumer.discover.OpenIDServiceEndpoint import fromXRDS [as 别名]
def create_service():
endpoint_type = 'production' if mojeid_settings.MOJEID_INSTANCE_PRODUCTION \
else 'testing'
defs = mojeid_services[endpoint_type]
return OpenIDServiceEndpoint.fromXRDS(defs['url'], defs['xrds'])[0]