Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 309
DavidWinterbottom Avatar asked Dec 06 '25 06:12

DavidWinterbottom


2 Answers

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

like image 108
Serxipc Avatar answered Dec 10 '25 10:12

Serxipc


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.

like image 32
Georg Schölly Avatar answered Dec 10 '25 09:12

Georg Schölly