How to get access token identity in asp.net webforms external login page? -
i'm using new microsoft identity manage website login , register.
i've configured website start using external login (facebook).
how can access token in (registerexternallogin) page?
``
protected void page_load(){ // process result auth provider in request providername = identityhelper.getprovidernamefromrequest(request); if (string.isnullorempty(providername)) { redirectonfail(); return; } if (!ispostback) { var manager = context.getowincontext().getusermanager<applicationusermanager>(); var logininfo = context.getowincontext().authentication.getexternallogininfo(); if (logininfo == null) { redirectonfail(); return; } var user = manager.find(logininfo.login); if (user != null) { identityhelper.signin(manager, user, ispersistent: false); identityhelper.redirecttoreturnurl(request.querystring["returnurl"], response); } else if (user.identity.isauthenticated) { response.write("ok.2"); // apply xsrf check when linking var verifiedlogininfo = context.getowincontext().authentication.getexternallogininfo(identityhelper.xsrfkey, user.identity.getuserid()); if (verifiedlogininfo == null) { redirectonfail(); return; } var result = manager.addlogin(user.identity.getuserid(), verifiedlogininfo.login); if (result.succeeded) { identityhelper.redirecttoreturnurl(request.querystring["returnurl"], response); } else { adderrors(result); return; } } else { try { var accesstoken = "what can access token"; response.write(accesstoken + "<br>"); var client = new facebookclient(accesstoken); //var client = new facebookclient(); dynamic me = client.get("me"); string firstname = me.first_name; string lastname = me.last_name; response.write(firstname + " " + lastname); } catch (exception ex) { response.write(ex.message); } email.text = logininfo.email; } } }
regards,
moayyad
Comments
Post a Comment