python social auth twitter 403后跟220

问题描述 投票:0回答:1

我正在尝试使用Python社交从Android授权,我正在以格式传递我的令牌:“xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”设置后端=“twitter”和“grant_type”:“convert_token”

我为Facebook做的事情也是如此。

我得到了适当的设置

SOCIAL_AUTH_TWITTER_KEY = os.environ.get('SOCIAL_AUTH_TWITTER_KEY', '')
SOCIAL_AUTH_TWITTER_SECRET = os.environ.get('SOCIAL_AUTH_TWITTER_SECRET', '')

但每当它在方法:user_data,即调用Twitters API verify_credentials.json端点时触及Twitter后端类。

它崩溃了400响应,然后:

{
  "error": "invalid_request",
  "error_description": "Backend responded with HTTP403: {\"errors\":[{\"message\":\"Your credentials do not allow access to this resource\",\"code\":220}]}."
}

我尝试手动重新创建东西,但同样的事情发生了。

我知道10月31日的Twitter API更改,我在Twitter的开发人员面板中添加了回调网址,包括应用和实时/开发服务器。

twittersdk://
http://127.0.0.1:8000/auth/complete/twitter/

我将权限更改为读取+写入以防万一,但没有用

Access permission
Read, write, and direct messages
Additional permissions
Request email address

此外,我已经两次刷新密钥和秘密,并小心地将它们放在后端和Android上。

在2018.10.31之前,同样的设置正在运行,但突然之间没有任何作用。

从Android我打电话:

TwitterCore.getInstance().getSessionManager().getActiveSession
                ().getAuthToken().token;

检索令牌。

Android使用https://api.twitter.com/1.1/account/verify_credentials.json检索令牌

更新

我在twurl(ruby应用程序)的帮助下手动测试

twurl authorize -u '[email protected]' -p 'mypassword' -c 'xxxxxxxxxxxxxxxxxxxxxxxxx' -s 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -a

然后在〜/ .twurlrc中有一个access_token(就像Android正在传递)。

但是,GET请求verify_credentials.json需要token_secret以及我调试的属性,我没有从Android上传递convert_token

图像显示成功:

Insomnia test reqyest

问题:我是否需要扩展Twitter后端并传递token_secret参数以及如何?

android twitter django-rest-framework python-social-auth
1个回答
0
投票

https://github.com/RealmTeam/django-rest-framework-social-oauth2/issues/15这里说我需要传递oauth_token_secret

 curl -X POST -d "grant_type=convert_token&client_id=<client_id>&backend=twitter&token=oauth_token=<token>%26oauth_token_secret=<secret_token>" http://localhost:8000/auth/api/convert-token

在请求中将此发送为application / x-www-form-urlencoded,可根据Android应用的需要进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.