I'm trying to handle the DeAuth callback from Facebook in my .Net MVC3, so that I can retrieve the UserId and remove the user from my database.
I've created an action that writes to a log file (for debugging purposes) using code from this answer:
FacebookApp app = new FacebookApp();
string accessToken = app.Session.AccessToken;
long userId = app.UserId;
At first my code failed with app
being null
. I then tried to add the CanvasAuthorizeAttribute
to the Controller
, which didn't help much either. Is there some other attribute I should have added instead? Or is there something else I'm wrong?
Edit:
I'm using version 4.2.1 of the SDK.
Edit 2: Thanks to Pat I figured out that the following code does the job (without any attributes on the action or controller).
var app = new FacebookApp();
var userId = app.SignedRequest.UserId;