Linq2Twitter MVC 授权返回空值
本文关键字:空值 返回 授权 MVC Linq2Twitter | 更新日期: 2023-09-27 18:32:36
我在我的应用程序(MVC5)中使用Linq2Twitter连接到twitter。授权后,我获得了OAuthTokenSecret,ScreenName的空值和UserID的0。我无法发推文,因为我没有OAuthTokenSecret。
我正在使用下面的代码...
授权
var auth = new MvcAuthorizer
{
CredentialStore = new SessionStateCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["twitterKey"],
ConsumerSecret = ConfigurationManager.AppSettings["twitterSecret"]//,
//OAuthToken = null,
//OAuthTokenSecret=null
}
};
return await auth.BeginAuthorizationAsync(redirectUri);
完成授权
var auth = new MvcAuthorizer
{
CredentialStore = new SessionStateCredentialStore()
};
auth.CompleteAuthorizeAsync(uri);
return auth;
PS:身份验证代码在服务层中。
您应该等待对 CompleteAuthorizeAync 的调用:
await auth.CompleteAuthorizeAsync(uri);
该方法在操作完成之前返回,这意味着你正在检查尚不可用的状态。