summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs')
-rw-r--r--src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs b/src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs
new file mode 100644
index 0000000..2235a2b
--- /dev/null
+++ b/src/DotNetOpenAuth.Web/Clients/OpenID/YahooOpenIdClient.cs
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
+using DotNetOpenAuth.OpenId.RelyingParty;
+
+namespace DotNetOpenAuth.Web.Clients
+{
+ internal sealed class YahooOpenIdClient : OpenIDClient
+ {
+ public YahooOpenIdClient() :
+ base("yahoo", "http://me.yahoo.com")
+ {
+ }
+
+ /// <summary>
+ /// Called just before the authentication request is sent to service provider.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
+ {
+ // Attribute Exchange extensions
+ var fetchRequest = new FetchRequest();
+ fetchRequest.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, isRequired: true));
+ fetchRequest.Attributes.Add(new AttributeRequest(AxKnownAttributes.FullName, isRequired: false));
+
+ request.AddExtension(fetchRequest);
+ }
+
+ /// <summary>
+ /// Gets the extra data obtained from the response message when authentication is successful.
+ /// </summary>
+ /// <param name="response">The response message.</param>
+ /// <returns></returns>
+ protected override Dictionary<string, string> GetExtraData(IAuthenticationResponse response)
+ {
+ FetchResponse fetchResponse = response.GetExtension<FetchResponse>();
+ if (fetchResponse != null)
+ {
+ var extraData = new Dictionary<string, string>();
+ extraData.AddItemIfNotEmpty("email", fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email));
+ extraData.AddItemIfNotEmpty("fullName", fetchResponse.GetAttributeValue(AxKnownAttributes.FullName));
+
+ return extraData;
+ }
+
+ return null;
+ }
+ }
+}