views:

162

answers:

3

I am using OpenID authentication in conjunction with traditional register/signin authentication on a site of mine. When someone signs in for the first time using OpenID, I would like to be able to extract a username for use on the site.

This is easy for some openid identifiers - eg:

http://username.myopenid.com/
http://username.livejournal.com/
http://claimid.com/username

However this isn't always the case as any URL can essentially be used as an OpenID.

One option is to maintain a list of URL formats as above where I know I can extract a username - and auto-assign a username in the other cases (which can be changed after signing in). Is there any other, more flexible way of extracting a username?

+2  A: 

OpenID has an API for getting user information like a name, email and so on. I'd just use the name if the user allows you to access it.

Georg
+1  A: 

Since OpenID is an authentication which works without username/password outside of the OpenID authenticating site but just with the URL, it is per se not possible to extract an unique username.

I think, that guessing an username from the url or auto-assigning one if the guessing is not possible (eg. Google) is the best you can get. Sorry.

Kosi2801
+3  A: 

This tutorial seems to cover what you want and more attributes.

Serhii