1
我有這樣的工作代碼:LinqToTwitter檢查授權
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"));
}
}
}
如果沒有授權存儲,它重定向到Twitter的認證請求。否則,它會繼續在頁面上。
我面臨的問題是,當用戶通過他們的Twitter帳戶撤銷對應用程序的訪問時,如何在此頁面上檢測到應用程序不再有權向用戶發佈Tweets並需要重新授權?