c# - DotNetOpenAuth and Hotmail Sign In -
how retrieve signin email id of hotmail using dotnetopenauth
i have tried code sample gives name , not email id
iauthorizationstate authorization = client1.processuserauthorization(null); if (authorization == null) { // kick off authorization request client1.requestuserauthorization(new[] { windowsliveclient.scopes.basic, "wl.emails" }, new uri("http://localhost/signin.aspx")); // scope isn't required log in } else { var request = webrequest.create("https://apis.live.net/v5.0/me?access_token=" + uri.escapedatastring(authorization.accesstoken)); using (var response = request.getresponse()) { using (var responsestream = response.getresponsestream()) { var graph = windowslivegraph.deserialize(responsestream); //this.namelabel.text = httputility.htmlencode(graph.name); } } }
you need add item scope
class
/// <summary> /// well-known scopes defined windows live service. /// </summary> /// <remarks> /// sample includes few scopes. complete list of scopes please refer to: /// http://msdn.microsoft.com/en-us/library/hh243646.aspx /// </remarks> public static class scopes { /// <summary> /// ability of app read , update user's info @ time. without scope, app can access user's info while user signed in live connect , using app. /// </summary> public const string offlineaccess = "wl.offline_access"; /// <summary> /// single sign-in behavior. single sign-in, users signed in live connect signed in website. /// </summary> public const string signin = "wl.signin"; /// <summary> /// read access user's basic profile info. enables read access user's list of contacts. /// </summary> public const string basic = "wl.basic"; /// <summary> /// read access user's personal, preferred, , business email addresses. /// </summary> public const string email = "wl.emails"; }
then can use following code passing in correct scope(s) - can see example can pass in 2 or more scopes. can find details of scopes offered here.
var windowsiveclient = windowsliveclient.instance(); var authorization = windowsiveclient.processuserauthorization(); if (authorization == null) { // kick off authorization request windowsiveclient.requestuserauthorization(scope: new[] { windowsliveclient.scopes.email, windowsliveclient.scopes.basic }); // retuning null force page redirect windows live , have not specified callback if authorized // return calling url - in instance 'attemptsigninforwindowliveopenid' controller action. return null; // } windowslivegraph windowslivemodel; var windowsliverequest = webrequest.create(string.format("https://apis.live.net/v5.0/me?access_token={0}", uri.escapedatastring(authorization.accesstoken))); using (var response = windowsliverequest.getresponse()) { using (var responsestream = response.getresponsestream()) { windowslivemodel = windowslivegraph.deserialize(responsestream); } }
Comments
Post a Comment