我试着打电话给这一行:
//First import this package
import HtmlWebpackPlugin from 'html-webpack-plugin';
//Then add this plugin
plugins: [
// Create HTML file that includes reference to bundled JS.
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: true,
})
]
每次我获得curl https://getpocket.com/v3/oauth/authorize --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"61999-492f79db0bd3292f0b4...1\",\"code\":\"c9166709-0c45-2b1f-a22f-e...r\"}"
。
我不知道并理解其原因。
有谁知道吗?我也尝试过Python:
403 Forbidden
上面的代码给了我一个代码:
import requests
auth_params = {'consumer_key': 'key_here', 'redirect_uri': 'https://www.twitter.com/'}
tkn = requests.post('https://getpocket.com/v3/oauth/request', data=auth_params)
tkn.content
这里我也得到usr_params = {'consumer_key': 'key_here', 'code': 'code_here'}
usr = requests.post('https://getpocket.com/v3/oauth/authorize', data=usr_params)
usr.content
。
我该如何解决?
答案 0 :(得分:3)
从Pocket Authentication API Documentation开始,您需要注册一个应用程序以获取使用者密钥,然后通过以下方式请求OAuth令牌:
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"consumer_key":"XXXXX-XXXXXXXXXXXXXXXXXXXXXX","redirect_uri":"AppTest:authorizationFinished"}' \
https://getpocket.com/v3/oauth/request
然后步骤2是授权此请求令牌(这是您缺少的步骤)。在浏览器中,使用您从上一步获得的请求令牌打开以下URL:
https://getpocket.com/auth/authorize?request_token=XXXXXXXX-XXXX-XXXX-XXXX-XXXX&redirect_uri=AppTest:authorizationFinished
点击"授权" :
授权请求令牌后,您可以在https://getpocket.com/v3/oauth/authorize
上调用您的请求,将请求令牌转换为Pocket访问令牌:
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"consumer_key":"XXXXX-XXXXXXXXXXXXXXXXXXX","code":"XXXXXXXXX-XXXX-XXXX-XXXX-XXXXX"}' \
https://getpocket.com/v3/oauth/authorize
使用者密钥是您在Pocket上创建应用程序时获得的密钥,而请求令牌是从v3/oauth/request
端点生成的密钥
然后你按预期得到了:
{ "access_token":"5678defg-5678-defg-5678-defg56", "username":"pocketuser" }