facebook c# sdk - Canvas authentication for c# asp.net and general principles -
i trying find general principles of using facebook c# sdk write canvas application.
my approach follows. have master page attempt authorise on oninit page. well. first time round not authorized , second time round are. when post goes wrong. have expected authorization / cookies / session item / viewstate item hang around , authorizer item remain authorised.
this appears not case.
should check authorization once , stick auth token in memory? when want information / post information, pass auth token in manually?
is general principle when want post / create new instance of facebookapp , pass in auth token?
here code using.
can general principles specific c#
, asp.ne
t, codeplex sdk dlls
many spiggers
public partial class facebook : system.web.ui.masterpage { protected facebookapp fbapp; protected canvasauthorizer authorizer; protected facebooksettings osettings = new facebooksettings(); protected override void oninit(eventargs e) { //not sure need this, or indeed if works //httpcontext.current.response.addheader("p3p", "cp=\"idc dsp cor adm devi taii psa psd ivai ivdi coni our ind cnt\""); osettings.appid = config.facebook.facebookapplicationid; osettings.appsecret = config.facebook.facebooksecret; fbapp = new facebookapp(osettings); authorizer = new canvasauthorizer(fbapp); if (!authorizer.isauthorized()) // postbacks fail this, reposts , postback event not fire!!! { string scope = "publish_stream,email,user_birthday"; var url = common.facebook.authorization.authurl(config.facebook.facebookapplicationid, config.facebook.redirecturl, scope); var content = canvasurlbuilder.getcanvasredirecthtml(url); response.contenttype = "text/html"; response.write(content); response.end(); } base.oninit(e); } }
Comments
Post a Comment