0

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.

Evgeny
  • 10,698
  • 9
  • 60
  • 70

1 Answers1

3

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
  • 272,464
  • 47
  • 358
  • 399
  • thanks looks good but does not work with xri://myprovider/myname according to OpenID spec string might be xri too – Evgeny Jul 06 '09 at 19:01
  • 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 Jul 06 '09 at 19:20