我正在尝试学习tweetinvi
凭证,所以我有以下 UI
和这两种方法,initAuthentication
和startAuthentication
private void initAuthentication()
{
var appCredentials = new TwitterCredentials(consumerKey, consumerSecret);
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
Process.Start(authenticationContext.AuthorizationURL);
//i am commenting the following code
//var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(textBox1.Text, authenticationContext);
//Auth.SetCredentials(userCredentials);
//so the user have some time to copy the pinCode
//paste them into available textbox
// and continue executing startAuthentication() by clicking authenticate button.
}
private void startAuthentication (string pinCode)
{
//if we split like this, the authenticationContext is error, because it doesn't exist in current context
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext);
Auth.SetCredentials(userCredentials);
}
如果我们将这两个部分加入一个功能,用户就没有时间将密码复制粘贴到文本框中。
但是,如果我们将这两个部分拆分为不同的功能,则用户需要一些时间将 pin 码复制粘贴到文本框中,但似乎authenticationContext
出错了,因为it doesn't exist in current context
有什么办法可以解决这个问题吗?