views:

100

answers:

1

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 - i.e. 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, e.g. for i-name IDs like "=somename". There are many other forms of valid OpenID string that don't even closely look like url.

Thanks.

+3  A: 

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
RichieHindle
+1: Since there's nothing in OpenIDEnabled that'll do this.
Nikhil Chelliah
thanks looks good but does not work with xri://myprovider/mynameaccording to OpenID spec string might be xri too
Evgeny
Since you don't need the scheme (http, xri, etc) you could just strip it and urlparse will still work fine: openid_str = re.sub(r'^\w+:', '', openid_str)
RichieHindle