简体   繁体   English

获取有关使用Python的XRI OpenID的简短人类可读信息?

[英]Get brief human-readable info about XRI OpenID with Python?

I'd like to be able to tell to the site visitor that comes with his/her OpenID: you are using your XYZ id for the first time on mysite - please create your sceen name , where XYZ is a nice token that makes sense. 我想告诉他/她的OpenID附带的网站访问者: 您是在mysite上第一次使用XYZ ID-请创建您的sceen名称 ,其中XYZ是一个很有意义的标记。 For example - XYZ could be the provider name. 例如-XYZ可以是提供者名称。

I'd like to find a solution that works for OpenID as defined in the standard - ie work for XRI type of ID - extensible resource identifier. 我想找到一种适用于标准中定义的OpenID的解决方案-即适用于ID的XRI类型-可扩展资源标识符。

urlparse (as suggested by RichieHindle) works for url-type openid, but does not work in general, eg for i-name IDs like "=somename". urlparse(由RichieHindle建议)适用于url类型的openid,但通常不适用于例如“ = somename”之类的i-name ID。 There are many other forms of valid OpenID string that don't even closely look like url. 有效OpenID字符串还有许多其他形式,甚至看起来都不像url。

Thanks. 谢谢。

Since OpenIDs are URLs, this might be the cleanest way in the absence of built-in support in Janrain: 由于OpenID是URL,因此在Janrain中缺少内置支持的情况下,这可能是最干净的方法:

from urlparse import urlparse
openid_str = "http://myprovider/myname" # str(openid_obj)
parts = urlparse(openid_str)
provider_name = parts[1]
print (provider_name)  # Prints myprovider

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

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