httr::oauth1.0_token 推特错误 api

httr::oauth1.0_token error with twitter api

我目前正在尝试通过 httr 包与 Twitter 的流媒体 API 互动:

library(httr)
my_app <- oauth_app('twitter', consumerKey, consumerSecret)
twitter_token <- oauth1.0_token(oauth_endpoints('twitter'), my_app)

这会引发以下问题和错误:

Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No
Selection: 2
Error in init_oauth1.0(endpoint, app, permission = params$permission) : 
  client error: (401) Unauthorized

我该如何解决这个问题?

如果您在使用 Twitter OAuth 时遇到问题,请首先检查回调 url 是否为 http://localhost:1410