Twitter Api 返回 "code":215,"message":"Bad Authentication data"通过 axios

问题描述

我通过 Python 的 requests.post 调用了这个 api,如下所示。 Twitter API

        headers = {'Authorization': 'OAuth oauth_timestamp="1615466796",oauth_consumer_key="xxxxxxxxxxxxx",oauth_nonce="d31d6684-55ed-466d-8349-016bced6c94e",oauth_callback="https%2Fxxxxxx%2F%2Fxxxxxx%2F",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="xxxxxxxxxxxxx"'}

    return requests.post(url,headers=headers)

它工作正常。 而且我也想像这样通过 axios 调用相同的 api。

 const response = await axios.post("/api/oauth/request_token",{
                headers: {
                    Authorization: 'OAuth oauth_timestamp="1615466796",oauth_signature="xxxxxxxxxxxxx"'
                }
            }

        )

但是我遇到了这个错误。

{"errors":[{"code":215,"message":"Bad Authentication data."}]}

有人知道是什么问题吗?

都是一样的Authentication header,那么axios有没有语法错误?

※ 我使用@nuxtjs/proxy 来避免 CORS 错误。

这里是nuxt.config.js的配置

 proxy: {
    '/api/': { 
      target: 'https://api.twitter.com',pathRewrite: {'^/api/': ''}
     }
  },

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...