c# LinqToTwitter 连接 OAuth PIN
c# LinqToTwitter Connection OAuth PIN
我在使用 OAuth PIN 授权方方法连接到 Twitter 时遇到以下问题。
代码:
private async void button1_Click(object sender, RoutedEventArgs e)
{
pinAuth = new PinAuthorizer
{
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = resourceLoader.GetString("ConsumerKey"),
ConsumerSecret = resourceLoader.GetString("ConsumerSecret")
},
GoToTwitterAuthorization = async pageLink =>
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>{ OAuthWebBrowser.Navigate(new Uri(pageLink, UriKind.Absolute)); })
};
await pinAuth.BeginAuthorizeAsync();
检索 PIN 码后,我会做类似的事情:
private async void button2_Click(object sender, RoutedEventArgs e)
{
string pin = null; // Cant get the PIN
await pinAuth.CompleteAuthorizeAsync(pin);
var credentials = pinAuth.CredentialStore;
string oauthToken = credentials.OAuthToken;
string oauthTokenSecret = credentials.OAuthTokenSecret;
string screenName = credentials.ScreenName;
ulong userID = credentials.UserID;
}
浏览器打开我将我的凭据输入表单并单击授权。单击此后,PIN 弹出半秒钟,然后出现以下错误消息:
"This page requires some information that was not provided. Please return to the site that sent you to this page and try again... it was probably an honest mistake"
同样的问题Thread目前还没有解决方案。
谢谢!
//更新
由于 3 天内没有任何回应,我允许自己用 Tweetinvi(我是开发者)给你一个替代示例。我了解到您正在尝试使用 LinqToTwitter,但我对图书馆的了解还不足以帮助您解决这个特定问题。
您可以在关联的 wiki section.
中找到有关身份验证的更多信息
// Create a new set of credentials for the application.
var appCredentials = new TwitterCredentials("CONSUMER_KEY", "CONSUMER_SECRET");
// Init the authentication process and store the related `AuthenticationContext`.
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
// Go to the URL so that Twitter authenticates the user and gives him a PIN code.
Process.Start(authenticationContext.AuthorizationURL);
// Ask the user to enter the pin code given by Twitter
var pinCode = Console.ReadLine();
// With this pin code it is now possible to get the credentials back from Twitter
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext);
// Use the user credentials in your application
Auth.SetCredentials(userCredentials);
希望对您有所帮助
我在使用 OAuth PIN 授权方方法连接到 Twitter 时遇到以下问题。
代码:
private async void button1_Click(object sender, RoutedEventArgs e)
{
pinAuth = new PinAuthorizer
{
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = resourceLoader.GetString("ConsumerKey"),
ConsumerSecret = resourceLoader.GetString("ConsumerSecret")
},
GoToTwitterAuthorization = async pageLink =>
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>{ OAuthWebBrowser.Navigate(new Uri(pageLink, UriKind.Absolute)); })
};
await pinAuth.BeginAuthorizeAsync();
检索 PIN 码后,我会做类似的事情:
private async void button2_Click(object sender, RoutedEventArgs e)
{
string pin = null; // Cant get the PIN
await pinAuth.CompleteAuthorizeAsync(pin);
var credentials = pinAuth.CredentialStore;
string oauthToken = credentials.OAuthToken;
string oauthTokenSecret = credentials.OAuthTokenSecret;
string screenName = credentials.ScreenName;
ulong userID = credentials.UserID;
}
浏览器打开我将我的凭据输入表单并单击授权。单击此后,PIN 弹出半秒钟,然后出现以下错误消息: "This page requires some information that was not provided. Please return to the site that sent you to this page and try again... it was probably an honest mistake"
同样的问题Thread目前还没有解决方案。
谢谢!
//更新
由于 3 天内没有任何回应,我允许自己用 Tweetinvi(我是开发者)给你一个替代示例。我了解到您正在尝试使用 LinqToTwitter,但我对图书馆的了解还不足以帮助您解决这个特定问题。
您可以在关联的 wiki section.
中找到有关身份验证的更多信息// Create a new set of credentials for the application.
var appCredentials = new TwitterCredentials("CONSUMER_KEY", "CONSUMER_SECRET");
// Init the authentication process and store the related `AuthenticationContext`.
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
// Go to the URL so that Twitter authenticates the user and gives him a PIN code.
Process.Start(authenticationContext.AuthorizationURL);
// Ask the user to enter the pin code given by Twitter
var pinCode = Console.ReadLine();
// With this pin code it is now possible to get the credentials back from Twitter
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext);
// Use the user credentials in your application
Auth.SetCredentials(userCredentials);
希望对您有所帮助