DavidWinterbottom
DavidWinterbottom

Reputation: 6540

Extracting a username from an OpenID identity

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?

Upvotes: 3

Views: 520

Answers (3)

Serxipc
Serxipc

Reputation: 6699

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

Upvotes: 3

Kosi2801
Kosi2801

Reputation: 23125

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.

Upvotes: 1

Georg Schölly
Georg Schölly

Reputation: 126145

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.

Upvotes: 2

Related Questions