How to get username with DotNetOpenAuth using Google

I have an ASP.NET MVC project that uses DotNetOpenAuth as an authentication provider. How do I get the username (or email address) when a user registers with https://www.google.com/accounts/o8/id ?

switch (response.Status)
    case AuthenticationStatus.Authenticated:
        string userOpenId = response.FriendlyIdentifierForDisplay;
        break;
(...)

      

+2


a source to share


1 answer


I hope your local variable userOpenId

is not what you are using for the username, because since the property you are assigning it from is aptly named, it is only displayed for display. You should only use IAuthenticationResponse.ClaimedIdentifier

for usernames.



As an aside, you can get the Google email address (you can never get the username) by sending a FetchRequest for the email marked as a required attribute. This has been asked many times, like this one .

+4


a source







All Articles