我已经设法授予用户的访问权,从而根据需要获得access_token
到retrieve the data from the Angellist API。使用NodeJS和请求从AngelList API进行简单的HTTPS GET
下一步是获取用户数据。我们可以从Angellist API阅读,您通过身份验证的HTTPS GET请求做到这一点:
Use the Token
Any requests that require authentication must be made using HTTPS, with the access token provided in the HTTP Authorization header, request body or query string. AngelList only supports Bearer tokens, as defined in http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-08 . An example using the query string:
GET https://api.angel.co/1/me?
access_token=...
要在的NodeJS的要求,我用的是故宫包request如下:
function testRequest(access_token) {
console.log('test request');
var urltest = "https://api.angel.co/1/me?access_token=" + access_token;
request.get(urltest,
{
'auth': {
'bearer': access_token
}
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log('body', body)
}
console.log('body', body)
console.log('error', error)
}
);
};
但是,我不断收到错误:
body {"success":false,"error":{"type":"unauthorized","message":"The authenticated user is not authorized for this request."}}
我在做什么错? access_token是否需要转换或者什么,即它不是一个不记名令牌?
您是否尝试过在邮递员或其他客户端使用api? –
当我通过一个url发送请求时,返回相同的错误。不知道如何用邮差添加持票人代币? – JohnAndrews
好吧,我在Postman中添加了一个标头:授权值“Bearer 12345token”,并返回相同的错误。 – JohnAndrews