我已經設法授予用戶的訪問權,從而根據需要獲得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