本文整理匯總了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]