标签: twitter-oauth

OAuth :: Unauthorized 401 int twitter-omniauth gem

我一直在尝试使用twitter-omniauthgem 验证用户的最后几天,但没有成功.(与facebook的身份验证工作完美)

我一直在收到401 Unauthorized错误.

我搜索stackoverflow,但没有一个答案可以解决我的问题.

我尝试时到达Twitter登录http://127.0.0.1/users/auth/twitter.我登录后,我被重定向到http://127.0.0.1/users/auth/twitter/callback未经授权的错误.

我在twitter中输入了回调网址

http://127.0.0.1/users/auth/twitter/callback

rake routes 产量

new_user_session GET    /users/sign_in(.:format)               {:action=>"new", :controller=>"devise/sessions"}
                user_session POST   /users/sign_in(.:format)               {:action=>"create", :controller=>"devise/sessions"}
        destroy_user_session DELETE /users/sign_out(.:format)              {:action=>"destroy", :controller=>"devise/sessions"}
      user_omniauth_callback        /users/auth/:action/callback(.:format) {:action=>/twitter|facebook/, :controller=>"users/omniauth_callbacks"}
               user_password POST   /users/password(.:format)              {:action=>"create", :controller=>"devise/passwords"}
           new_user_password GET    /users/password/new(.:format)          {:action=>"new", :controller=>"devise/passwords"}
          edit_user_password GET    /users/password/edit(.:format)         {:action=>"edit", :controller=>"devise/passwords"}
                             PUT    /users/password(.:format)              {:action=>"update", :controller=>"devise/passwords"}
    cancel_user_registration GET    /users/cancel(.:format)                {:action=>"cancel", :controller=>"devise/registrations"}
           user_registration POST   /users(.:format)                       {:action=>"create", :controller=>"devise/registrations"}
       new_user_registration GET    /users/sign_up(.:format)               {:action=>"new", :controller=>"devise/registrations"}
      edit_user_registration GET    /users/edit(.:format)                  {:action=>"edit", :controller=>"devise/registrations"}
                             PUT    /users(.:format)                       {:action=>"update", :controller=>"devise/registrations"}
                             DELETE …
Run Code Online (Sandbox Code Playgroud)

twitter-gem twitter-oauth ruby-on-rails-3

15
推荐指数
2
解决办法
9577
查看次数

TwitteR,ROAuth和Windows:注册正常,但证书验证失败

我正试图获得大量Twitter用户的追随者数量twitteR.发布的其他 许多问题对我这么做很有用,但就我所知,似乎没有一个与我的问题直接相关.

我可以将我的OAuth凭证注册到twitter R会话,但是我似乎根本无法做任何事情,我得到的是这条消息:

Error in function (type, msg, asError = TRUE) : SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify fail

当我在twitteR不使用OAuth的情况下使用这些功能时,它们可以正常工作,没有任何错误或警告,但我遇到限制和受保护的帐户,我认为我可以避免使用OAuth.

以下是详细信息:

library(twitteR)
library(ROAuth)
library(RCurl)
#
# Here's how I register my credentials
#
requestURL <-  "https://api.twitter.com/oauth/request_token"
accessURL =    "https://api.twitter.com/oauth/access_token"
authURL =      "https://api.twitter.com/oauth/authorize"
consumerKey =   "------------"
consumerSecret = "-----------"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
                             consumerSecret=consumerSecret,
                             requestURL=requestURL,
                             accessURL=accessURL,
                             authURL=authURL)
download.file(url="http://curl.haxx.se/ca/cacert.pem",
              destfile="cacert.pem")
twitCred$handshake(cainfo="cacert.pem")
To enable the connection, please direct …
Run Code Online (Sandbox Code Playgroud)

twitter r twitter-oauth

15
推荐指数
2
解决办法
2万
查看次数

Spring Security oauth2 客户端 - Twitter 问题

我想将 Twitter oAuth2 添加到我的应用程序中。早些时候,我成功添加了 Facebook 和 google - 我不必添加提供商。当我尝试将 twitter 数据添加到application.properties文件并运行服务器时,出现错误:

Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'securityConfig': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration': Unsatisfied dependency expressed through method 'setClientRegistrationRepository' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientRegistrationRepositoryConfiguration': …
Run Code Online (Sandbox Code Playgroud)

java twitter-oauth spring-boot spring-security-oauth2

15
推荐指数
1
解决办法
2065
查看次数

Twitter4J + Android:身份验证挑战是无效的

我正在使用Twitter4J库进行OAuth身份验证,但即使在它打开Twitter登录页面之前,我也会收到"身份验证挑战是空的例外".

这是代码.

    Twitter twitter = new TwitterFactory().getInstance();
    try
    {

        twitter.setOAuthConsumer(Startup.TWITTER_KEY, Startup.TWITTER_SECRET);

        String callbackURL = "twitter-client:///";

        RequestToken rToken = twitter.getOAuthRequestToken(callbackURL);

        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(rToken.getAuthenticationURL())));

    }
    catch(IllegalStateException e)
    {
    // access token is already available, or consumer key/secret is not set.
        if(!twitter.getAuthorization().isEnabled()){
            System.out.println("OAuth consumer key/secret is not set.");
            System.exit(-1);
        }
    }
    catch(Exception e)
    {
        Toast.makeText(Home.this, "Network Host not responding: "+e.getMessage(),Toast.LENGTH_SHORT).show();  //This exception. 
    }
Run Code Online (Sandbox Code Playgroud)

例外:

E/Home(4393):接收的认证质询为空E/Home(4393):接收的认证质询为null相关的讨论可以在因特网上:E/Home(4393):http: //www.google.co.jp/search?q = 6c607809 或E/Home(4393):http: //www.google.co.jp/search ?q = 0f1d8134 E/Home(4393):TwitterException {exceptionCode = [6c607809-0f1d8134 cab4c0ac-d492a113] ,statusCode …

twitter android oauth twitter4j twitter-oauth

14
推荐指数
1
解决办法
8914
查看次数

iPhone网络应用中的OAuth回调

我正在构建一个全屏iPhone优化的网络应用程序.它像主机应用程序一样从主页启动,并且通过以下指令表现得像一个独立的应用程序,但它只是简单的HTML/CSS/JavaScript,没有涉及PhoneGap.

<meta name="apple-mobile web-app-capable" content="yes" />
Run Code Online (Sandbox Code Playgroud)

尝试通过OAuth进行身份验证时,重定向到Twitter(或任何其他OAuth提供商)会将我从我的全屏网络应用程序转移到Mobile Safari中.Twitter身份验证完成后,重定向回我的应用程序不会启动我的主页应用程序,而只是在Mobile Safari中重定向.是否可以在iPhone主页Web应用程序中执行OAuth?除此之外,我可以获得OAuth回调以重新启动我的主页Web应用程序吗?

iphone oauth iphone-web-app twitter-oauth iphone-standalone-web-app

14
推荐指数
1
解决办法
3768
查看次数

Zend_Service_Twitter - 准备好API v1.1

Zend_Service_Twitter组件仍然适用于Twitters API v1.0,将于2013年3月5日弃用.因此,我希望使用Twitter API交互v1.1准备好我的新网站.一切工作正常V1.0,但如果我从更改URL /1//1.1/失败与HTTP标头码400和JSON错误信息:Bad Authentication data(代码:215)

为了获得请求和访问令牌保持不变并且已经没有任何更改,但是如果我想验证这样的凭据,我得到上面描述的错误:

// Take a look for the code here: http://framework.zend.com/manual/1.12/en/zend.oauth.introduction.html
$accessToken = $twitterAuth->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));


// I have a valid access token and now the problematic part
$twitter = new Zend_Service_Twitter(array(
    'username' => $accessToken->getParam('screen_name'),
    'accessToken' => $accessToken
));
print_r($twitter->account->verifyCredentials());
Run Code Online (Sandbox Code Playgroud)

我将verifyCredentials的代码Zend/Service/Twitter.php从那里更改为:

public function accountVerifyCredentials()
{
    $this->_init();
    $response = $this->_get('/1/account/verify_credentials.xml');
    return new Zend_Rest_Client_Result($response->getBody());
}

// to

public function accountVerifyCredentials()
{
    $this->_init();
    $response = $this->_get('/1.1/account/verify_credentials.json');
    return Zend_Json::decode($response->getBody());
}
Run Code Online (Sandbox Code Playgroud)

现在我在return …

php twitter zend-framework twitter-oauth

14
推荐指数
2
解决办法
6100
查看次数

如何在不达到API限制的情况下获取所有Twitter粉丝

我想这很容易做到,但我无法弄清楚我做错了什么.我正在使用亚伯拉罕的OAuth获取访问权限.我正在使用我的关注者信息构建一个数据库:屏幕名称,用户名和推特ID.没什么特别的.

我引用了Twitter的" 光标 "页面,特别是伪代码,来制作我的代码.对于那些不想单击链接以查看所述pesudo代码的人,它看起来如下所示:

cursor = -1

api_path = "https://api.twitter.com/1.1/endpoint.json?screen_name=targetUser"

do {

    url_with_cursor = api_path + "&cursor=" + cursor      

    response_dictionary = perform_http_get_request_for_url( url_with_cursor )

    cursor = response_dictionary[ 'next_cursor' ]

}

while ( cursor != 0 )
Run Code Online (Sandbox Code Playgroud)

对于每个请求,最终用户都会获得一个"光标",允许他们浏览结果的"页面".每页有20个,如果你有200个粉丝,你必须经历10页.我有900多名粉丝.我将其修改为如下所示:

 include('config.php');  //db connection
 include('twitter_oauth.php'); //oauth connection

 $followers = "";

$cursor = -1;
echo '<pre>';   
do {

    $consumerKey = 'xxx';
    $consumerSecret = 'xxx';
    $OAuthToken = 'xxx';
    $OAuthSecret = 'xxx';

    $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret);

    $followers = $tweet->get('followers/list', array('screen_name' => 'my_screen_name', 'cursor' => …
Run Code Online (Sandbox Code Playgroud)

php twitter oauth twitter-oauth

13
推荐指数
1
解决办法
1万
查看次数

使用Twitter流API,是否可以只显示特定用户的推文?

我目前正在使用Twitter API来检索某些用户发布的推文.为了这个问题,我们将以@justinbieber为例.

使用https://stream.twitter.com/1.1/statuses/filter.json资源时,设置跟随所需的用户ID(@justinbieber = 27260086),并允许它运行,而我只想要@ justinbieber的推文我最终收到了他数百万粉丝发给他的推文.显然这意味着我得到的信息比我想要的多,而且从我发现的内容来看,我有时最终错过了用户自己的推文!

我尝试更改https://dev.twitter.com/docs/streaming-apis/parameters上的每个参数都无济于事.

以下参数说明:

For each user specified, the stream will contain:

   Tweets created by the user.
   Tweets which are retweeted by the user.
   Replies to any Tweet created by the user.
   Retweets of any Tweet created by the user.
   Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).
Run Code Online (Sandbox Code Playgroud)

正如在文档中那样,我会假设没有办法只获取用户的推文而不必自己过滤结果(如前所述,这意味着我最终可能会错过用户自己的推文!)但是我很想知道是否有人知道解决方法.

在任何人建议使用诸如status/user_timeline之类的东西之前,我知道它能够做我想要的,但是它有两个缺点让我继续使用流API:

  • 每个请求都意味着我失去了一个请求,而且由于Twitter的速率有限,我想避免这种情况.
  • 每个请求都有HTTP协议的高成本开销.谈判花费了太多时间.

我想做什么?@justinbieber只是一个高开销的Twitter账户的一个例子.我想使用此代码来检索许多高开销帐户的推文,从而提高速度,并且能够查看每个用户的每条推文都是需求.

api twitter twitter-oauth twitter-streaming-api

13
推荐指数
2
解决办法
1832
查看次数

Twitter连接失败

在Android中,
Twitter连接失败.需要SSL吗?

我的代码工作得很好,目前它是一个实时应用程序.然而,自2014年以来它一直没有工作,我听说Twitter已经应用了https或使用SSL概念.

帮我解决了这个问题.

这是我的日志.

 03-14 15:00:02.838: D/TwitterApp(697): Error getting access token
03-14 15:00:02.878: W/System.err(697): 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
03-14 15:00:02.878: W/System.err(697): message - SSL is required
03-14 15:00:02.878: W/System.err(697): code - 92
03-14 15:00:02.878: W/System.err(697): Relevant discussions can be found on the Internet at:
03-14 15:00:02.878: W/System.err(697):  http://www.google.co.jp/search?q=6f0f59ca or
03-14 15:00:02.888: W/System.err(697): …
Run Code Online (Sandbox Code Playgroud)

twitter ssl android twitter4j twitter-oauth

13
推荐指数
1
解决办法
7015
查看次数

使用twitteR自动进行httr身份验证,在"批处理"模式下提供对交互式提示的响应

我正在使用R包twitteR将项目发布到Twitter.我把所有东西都放在一个函数中,它工作正常.但是,我想在没有提示响应的情况下运行该函数,我还没想出如何做到这一点.有什么建议?

以下是我的功能:

doit <- function(<snip>) {
    <snip>
    # connect to Twitter
    setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)
    <snip>
    }
Run Code Online (Sandbox Code Playgroud)

当我从命令行运行该函数时,系统会提示我进行交互式响应.

[1] "Using direct authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

Selection: 
Run Code Online (Sandbox Code Playgroud)

当setup_twitter_oauth()函数在函数之外时,我可以通过在以下行中输入我的响应来直接在脚本中提供此信息,这与其他用户输入函数(如readline()或scan())非常相似.

setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)
1
Run Code Online (Sandbox Code Playgroud)

但是,当setup_twitter_oauth()是函数的INSIDE时,我无法使用此方法.

我将不胜感激任何有关如何在不需要用户输入的情况下运行此建议的建议.

=====

来自@NicE的答案就是诀窍.我将我的功能中的选项设置合并为:

doit <- function(<snip>) {
    <snip>
    # connect to Twitter
    origop <- options("httr_oauth_cache")
    options(httr_oauth_cache=TRUE)
    setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)
    options(httr_oauth_cache=origop)
    <snip>
    }
Run Code Online (Sandbox Code Playgroud)

r batch-processing twitter-oauth

13
推荐指数
1
解决办法
7198
查看次数