- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Twitter 最近刚刚强制执行以下内容:
1) 您必须将 oauth_callback
值传递给 oauth/request_token。这不是可选的。即使您已经在 dev.twitter.com 上设置了一个。如果您正在执行带外 OAuth,请传递 oauth_callback=oob
。
2) 您必须将您从执行的回调中收到的或您收到的最终用户手动输入的 oauth_verifier
传递给 oauth/access_token。这是推特主题 ( https://dev.twitter.com/discussions/16443 )
这导致 Twython get_authorized_tokens
抛出此错误:
Request: oauth/access_token
Error: Required oauth_verifier parameter not provided
我有两个问题:
<强>1。如何使用 Twython 将 oauth_callback
值传递给 oauth/request_token?
<强>2。您如何传递 oauth_verifier
?
我可以使用 request.GET['oauth_verifier'] 从回调 url 获取 oauth_verifier
但我不知道使用 Twython 从那里做什么。我到处搜索但没有找到任何答案所以我决定发布这个。这是我的第一篇文章,所以请善待 ;)
这是我的代码:
def register_twitter(request):
# Instantiate Twython with the first leg of our trip.
twitter = Twython(
twitter_token = settings.TWITTER_KEY,
twitter_secret = settings.TWITTER_SECRET,
callback_url = request.build_absolute_uri(reverse('account.views.twitter_thanks'))
)
# Request an authorization url to send the user to
auth_props = twitter.get_authentication_tokens()
# Then send them over there
request.session['request_token'] = auth_props
return HttpResponseRedirect(auth_props['auth_url'])
def twitter_thanks(request, redirect_url=settings.LOGIN_REDIRECT_URL):
# Now that we've got the magic tokens back from Twitter, we need to exchange
# for permanent ones and store them...
twitter = Twython(
twitter_token = settings.TWITTER_KEY,
twitter_secret = settings.TWITTER_SECRET,
oauth_token = request.session['request_token']['oauth_token'],
oauth_token_secret = request.session['request_token']['oauth_token_secret'],
)
# Retrieve the tokens
authorized_tokens = twitter.get_authorized_tokens()
# Check if twitter user has a UserProfile
try:
profile = UserProfile.objects.get(twitter_username=authorized_tokens['screen_name'])
except ObjectDoesNotExist:
profile = None
最佳答案
我解决了我自己的答案。如果它可以帮助其他人,这是解决方案:
在文件 Twython.py 中,我向 Twython 类构造函数添加了一个新参数 oauth_verifier
。我从我的 twitter_thanks View 中的 callback_url
获取了 oauth_verifier
值。
在 get_authorized_tokens
中,我删除了这行代码:
response = self.client.get(self.access_token_url)
并添加了以下代码:
callback_url = self.callback_url or 'oob'
request_args = urllib.urlencode({'oauth_callback': callback_url, 'oauth_verifier':self.oauth_verifier })
response = self.client.post(self.access_token_url, params=request_args)
它现在工作得很好,并且符合 OAuth 1.0A 标准。
关于python - 如何使用 Twython 将 oauth_callback 值传递给 oauth/request_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15841155/
我刚刚在我的 Linux 主机上编译了 QTweetLib。我已编译并运行 pinauthstatusupdate 示例,没有任何更改。但是当我尝试获取 request_token 时,我得到了: F
我目前正在为 qml 环境使用 javascript 和 OAuth 开发 Twitter 应用程序。我被困在“request_token”端点,我不明白为什么。当我发送我的请求时,我只会收到“无法验
我这里有一些代码,我收到错误 401 未经授权。我已经检查了使用 Twitter 框登录。 public async Task get_Oauth_token_TaskAsync() {
我成功地分别使用了 openID 和 OAuth,但我无法让它们一起工作。 我是不是做错了什么: String userSuppliedString = "https://www.google.com
我正在尝试为我的应用获取 oauth token 。我关注了this tutorial但我收到这样的错误: { "errors": [ { "code": 32,
尝试获取一个时收到http 403响应错误请求 token 。 我已经检查了我的基弦的歌唱过程,这是正确的。如果 我使用 Twitter 开发站点上的默认 key ,它生成相同的他们在网站上列出的结果
我已按照回复帖子 withings api authentication 的步骤中所述设置了所有内容. 但是,当我复制并粘贴在第 2 步(向 URL 发送请求:)中生成的最终 URL 时,我的浏览器没
所以,我在为我的 Angular 应用程序制作 Twitter 登录方法时遇到了问题。问题是我什至无法完成第一步。我需要向 request_token API 发出发布请求(我正在执行此步骤 http
我正在使用以下方法 URI 从 Twitter 请求 token 。 注意:这里的新行仅用于显示目的。 http://twitter.com/oauth/request_token? oauth_co
我正在尝试将 oauth 流程集成到我的应用程序中。 调用 oauth/request_token 端点时收到 401 错误: "message": "401 - {\"errors\":[{\"co
这可能是一个重复的问题,但还没有答案。库 oauth-dot-net 和 DotNetOpenAuth 都非常复杂,一个似乎贯穿 OAuth 的主题,虽然 OAuth with Verificatio
所以我正在尝试从 Twitter 获取 token ,但失败了。我收到以下错误:“无法验证 oauth 签名和 token ”。我读过这可能是由于您的系统时钟错误。在 javascript 中,我使用
我正在尝试在 NodeJS 上使用 OAuth 进行身份验证,但出现此错误: Error getting OAuth request token : { statusCode: 401, data:
我正在尝试在我的 Game Maker 应用程序中使用 Twitter 通过 OAuth 向 Firebase 验证用户(Game Maker 不支持 SDK)。 通过 REST HTTP POST
Twitter 最近刚刚强制执行以下内容: 1) 您必须将 oauth_callback 值传递给 oauth/request_token。这不是可选的。即使您已经在 dev.twitter.com
我正在编写一个简单的 Twitter 登录并尝试获取请求 token 以将用户重定向到访问 token ,但我总是以无法验证您错误结束我试图将签名添加为最后一个 header ,但它也不起作用。当我删
我尝试通过 https://api.twitter.com/oauth/request_token 请求 token 但总是收到 401 错误。 我通过 curl 进行测试(很容易看到会发生什么)。
(注意如果你不懂clojure我可以用Java翻译代码,请问) 我将 scribe 与 clojure 一起使用,我发现使用 Twitter 登录时存在一些问题,我正在使用的代码: (def twit
我正在尝试使用 RestSharp访问 Etsy 的 API。这是我用来尝试获取 OAuth 访问 token 的代码: var authenticator = OAuth1Authe
从早上开始,我就一直在努力了解如何在我的 webApp (Spring-MVC) 和 Spring-Social 之间实现登录功能。我正在使用 XML 配置,看起来效果很好。我在使用 Twitter
我是一名优秀的程序员,十分优秀!