I have this working code:
public AspNetAuthorizer Authoriser { get; set; }
protected async void Page_Load(object sender, EventArgs e)
{
var currentUser = v2.Membership.Functions.GetLoggedInAsUser();
Authoriser = v3.Twitter.Auth.GetUserAuthorizer(currentUser.UserID,
v3.Arcade.Settings.TwitterScirraArcadeAppAppName, v3.Arcade.Settings.TwitterScirraArcadeAppConsumerKey,
v3.Arcade.Settings.TwitterScirraArcadeAppConsumerSecret);
if (!Page.IsPostBack && Request.QueryString["oauth_token"] != null)
{
await Authoriser.CompleteAuthorizeAsync(Request.Url);
var credentials = Authoriser.CredentialStore;
v3.Twitter.Auth.SaveAuthorisationDetails(currentUser.UserID,
v3.Arcade.Settings.TwitterScirraArcadeAppAppName, credentials.OAuthToken, credentials.OAuthTokenSecret,
credentials.ScreenName);
}
else
{
if (!Authoriser.CredentialStore.HasAllCredentials())
{
await Authoriser.BeginAuthorizeAsync(new Uri("https://127.0.0.1/newarcade/twitterpopup.aspx"));
}
}
}
If no authorisation is stored, it redirects to Twitter authentication request. Otherwise, it continues on the page.
The problem I am facing is when a user revokes access to the app via their Twitter account, how can I detect on this page that the app no longer has permission to post Tweets for the user and needs reauthorising?