简体   繁体   中英

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. For example - XYZ could be the provider name.

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.

urlparse (as suggested by RichieHindle) works for url-type openid, but does not work in general, eg for i-name IDs like "=somename". There are many other forms of valid OpenID string that don't even closely look like url.

Thanks.

Since OpenIDs are URLs, this might be the cleanest way in the absence of built-in support in 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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