資格情報を学習しようとしtweetinvi
ているので、次の UI があります
そしてこれら2つの方法、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);
}
両方の部分を 1 つの関数に結合すると、ユーザーが PIN コードをコピーしてテキスト ボックスに貼り付ける時間がなくなります。
ただし、両方の部分を別の機能に分割すると、ユーザーが PIN コードをテキスト ボックスにコピー ペーストする時間がありますが、authenticationContext
エラーが発生したようです。it doesn't exist in current context
これを解決する方法はありますか?