Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request email address from OpenID provider

I'm implementing OpenID and I would like to retrieve the user's email address and other information about the user, I'm doing this:

var fetch = new FetchRequest();
fetch.AddAttribute(new AttributeRequest(WellKnownAttributes.Contact.Email));
request.AddExtension(fetch);

But the provider doesn't return anything. I'm using DotNetOpenID

What am I doing wrong?

thanks!

EDIT:

When I try to signup at http://www.plaxo.com/ using MyOpenID or Google, they both say plaxo is requesting additional information, but when I test my site they doesn't say anything...

like image 673
Bruno Avatar asked Feb 27 '09 12:02

Bruno


People also ask

How do I get an Azure AD email address?

In the Azure portal for the AD tenant you are configured against. If you go to App registrations, select the App name you want to configure and then select Token configuration. You can add an optional parameter of email. This requires OpenID connect scopes to also be configures.

Is Google OpenID provider?

Google's OAuth 2.0 APIs can be used for both authentication and authorization. This document describes our OAuth 2.0 implementation for authentication, which conforms to the OpenID Connect specification, and is OpenID Certified.


1 Answers

As Martin said, it depends on the Provider.

MyOpenID doesn't do AttributeExchange, I think. They do sreg (Simple Registration) though, so add a ClaimsRequest extension to your request and you'll get a ClaimsResponse back from some Providers.

Google only does AttributeExchange, and only provides an email address. The only thing you're missing from your code is that Google also doesn't even volunteer the email address unless you mark it as "Required" in your request. Add a ", true" second parameter to the AttributeRequest constructor and then Google should light up and give you the users' email address.

Here are some docs and samples of getting attributes.

like image 200
Andrew Arnott Avatar answered Jan 03 '23 12:01

Andrew Arnott