views:

248

answers:

1

I am running dotnetopenauth 3.3.0.9283 (nightly build), it works great and it solved my previous problem ( http://stackoverflow.com/questions/1539671/dotnetopenauth-get-email-and-redirect-problem )

So now I am able to get the users email from gmail only! I have tried yahoo and myspace but i always get "Object reference not set to an instance of an object." I ran the sample that came with the build, ajaxlogin.aspx and loginProgrammatic.aspx they both give me the same error message.

this is the only line i added to the sample (and also set email to required)

var email = OpenIdAjaxTextBox1.AuthenticationResponse.GetExtension<ClaimsResponse>().Email;
+2  A: 

You've got too much code on one line.

GetExtension<T>() will return null if the Provider doesn't actually include that extension in the response. So you must always check that it returns a non-null value before dereferencing it.

You're getting null back from Yahoo because they don't support giving away their users' extra information (yet) except for a small whitelist of RPs.

I don't know about MySpace, but I suspect they just don't support it either.

Andrew Arnott
thanks again Andrew, I tried some more providers and I managed to get the email from some of them. And I also asked yahoo to put me on the whitelist hop they do it. Thanks again :)
Murre
How can I know that a certain provider doesn't provide a certain information?
LuRsT
LuRsT, It's impossible to know for sure in advance. But if you request the information you just check for it in the response, as I state in my answer.
Andrew Arnott