I’ve just been (re)reading Rob Conery’s 2010 blog post OpenID is a Nightmare as part of some research into OpenID/OpenAuth. Ideally, I’m looking to use multiple OAuth providers linked to a single account, to provide resilience against the providers being unavailable – log in with Facebook, link your Twitter and Google accounts, and if next time you visit Facebook login isn’t working it doesn’t matter, you can use Twitter OR Google to get in and access your stuff – just as, in the real world, you can open a bank account with a passport, and withdraw money later using your driving license if your passport’s not available.
One of Rob’s primary concerns in his article is that there’s no way to consistently identify a user who’s using OpenID – somebody might log in with Google one day, buy a product, then come back and log in with Google a few days later and be unable to access the product they bought, because there’s no unique identifier that’s guaranteed to remain consistent between the two Google authentication calls.
I’m curious as to whether this has been addressed in OAuth 2.0 – either explicitly via the protocol spec, or via some implementation consensus amongst the major providers. Which field – if any – can I rely on not to change for the lifetime of a user’s relationship with a particular OAuth provider?
As part of their OAuth2 for login process, Google provide a
TokenInfoendpoint that is used to validate and provide information about theaccess_tokenthat is obtained earlier in the process.The token information includes
userid:which sounds like just the ticket (or perhaps token)!
useridis only present if thehttps://www.googleapis.com/auth/userinfo.profilescope was included in the access token request, so don’t forget that.Similarly, in the Facebook API you have access to the graph API once you’ve obtained an access token where you can get user data, including ID.
Twitter include the
user_idin the access token response as part of their authentication APIIf you’re using OAuth in a .NET project this might be useful… I discovered today that WebMatrix 2 Beta includes OAuth2 clients for Facebook, Twitter, Windows Live, Google and Yahoo, and can be used from an MVC project. I’m told that you just need the
WebMatrix.Security.dlland you’re good to go. It’s installed intoC:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies. Although it’s in beta and hidden away, it’s a good way to get started and might make the the learning curve with the DotNetOpenAuth library a bit less steep.