I have managed to grant access from the user, thus to get the access_token
as needed to retrieve the data from the Angellist API.
The next step is to fetch the user data. As we can read from the Angellist API, you do this by authenticated HTTPS GET requests:
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=...
To make the request in NodeJS, I use the npm package request as follows:
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)
}
);
};
However, I keep getting the error:
body {"success":false,"error":{"type":"unauthorized","message":"The authenticated user is not authorized for this request."}}
What am I doing wrong? Does the access_token need to be converted or something, i.e. it is not a bearer token?