Discogs API:除了“401 You must authenticate to access this resource.”之外无法得到任何其他信息。
Discogs API : Can't get anything else than "401 You must authenticate to access this resource."
我像文档说的那样执行了 Oauth 流程并获得了 oauth_token 和 oauth_token_secret,然后从我的 nodejs 服务器我尝试了这个请求:
request.get({
headers: {
"User-Agent": "FooBarApp/3.0",
"Authorization": {
oauth_token:"my token",
oauth_token_secret: "my secret token",
"OAuth oauth_consumer_key":"mykey",
"oauth_nonce":Date.now(),
"oauth_signature":"mypass&",
"oauth_signature_method":"PLAINTEXT",
"oauth_timestamp":Date.now(),
"oauth_verifier":"users_verifier"
},
"Content-Type": "application/x-www-form-urlencoded"
},
url: "https://api.discogs.com/oauth/identity"
我还尝试删除 "authorization" 中的所有参数,除了我的两个标记,但没有任何效果。有什么线索吗?
文档有误,Discogs 可能懒得更新了。我已尝试将文档更正发送给技术团队,但这是一条死胡同。
他们的身份验证机制不符合 OAuth 1.0 修订版 A 标准,即使他们以其他方式做广告。
同时,这里是 headers 您需要进行 身份验证请求:
const request = require('request');
const options = {
url: 'https://api.discogs.com/oauth/identity',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'OAuth oauth_consumer_key="YOUR_CONSUMER_KEY", oauth_nonce="' + Date.now() + '", oauth_token="OAUTH_TOKEN_RECEIVED_FROM_STEP_4", oauth_signature="YOUR_CONSUMER_SECRET&OAUTH_TOKEN_SECRET_RECEIVED_FROM_STEP_4", oauth_signature_method="PLAINTEXT", oauth_timestamp="' + Date.now() + '"',
'User-Agent': 'YOUR_USER_AGENT/1.0'
}
};
request(options, (err, res, body) => {
if (!err && res.statusCode == 200) {
console.log(JSON.parse(body));
}
});
祝你好运!
我像文档说的那样执行了 Oauth 流程并获得了 oauth_token 和 oauth_token_secret,然后从我的 nodejs 服务器我尝试了这个请求:
request.get({
headers: {
"User-Agent": "FooBarApp/3.0",
"Authorization": {
oauth_token:"my token",
oauth_token_secret: "my secret token",
"OAuth oauth_consumer_key":"mykey",
"oauth_nonce":Date.now(),
"oauth_signature":"mypass&",
"oauth_signature_method":"PLAINTEXT",
"oauth_timestamp":Date.now(),
"oauth_verifier":"users_verifier"
},
"Content-Type": "application/x-www-form-urlencoded"
},
url: "https://api.discogs.com/oauth/identity"
我还尝试删除 "authorization" 中的所有参数,除了我的两个标记,但没有任何效果。有什么线索吗?
文档有误,Discogs 可能懒得更新了。我已尝试将文档更正发送给技术团队,但这是一条死胡同。
他们的身份验证机制不符合 OAuth 1.0 修订版 A 标准,即使他们以其他方式做广告。
同时,这里是 headers 您需要进行 身份验证请求:
const request = require('request');
const options = {
url: 'https://api.discogs.com/oauth/identity',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'OAuth oauth_consumer_key="YOUR_CONSUMER_KEY", oauth_nonce="' + Date.now() + '", oauth_token="OAUTH_TOKEN_RECEIVED_FROM_STEP_4", oauth_signature="YOUR_CONSUMER_SECRET&OAUTH_TOKEN_SECRET_RECEIVED_FROM_STEP_4", oauth_signature_method="PLAINTEXT", oauth_timestamp="' + Date.now() + '"',
'User-Agent': 'YOUR_USER_AGENT/1.0'
}
};
request(options, (err, res, body) => {
if (!err && res.statusCode == 200) {
console.log(JSON.parse(body));
}
});
祝你好运!