2014-01-16 84 views
2

我一直在試圖獲得與下面的鏈接訪問JSON結果:使用訪問令牌與SkyDrive的API

https://apis.live.net/v5.0/file.a4423f3123801749.A4423F3123801749!418

但你可以通過點擊它看到自己,你需要一個訪問令牌。 我已經有一個訪問令牌,但它只能持續3600秒(1小時)。

有沒有辦法獲得鏈接的結果(JSON如下所示)沒有訪問令牌過期?我知道有一個刷新令牌,但我不確定如何使用它。

{ 
    "id": "file.a4423f3123801749.A4423F3123801749!418", 
    "from": { 
     "name": "Andrew Wong", 
     "id": "a4423f3123801749" 
    }, 
    "name": "Mod Permissions.xlsx", 
    "description": "", 
    "parent_id": "folder.a4423f3123801749.A4423F3123801749!129", 
    "size": 89956, 
    "upload_location": "https://apis.live.net/v5.0/file.a4423f3123801749.A4423F3123801749!418/content/", 
    "comments_count": 0, 
    "comments_enabled": true, 
    "is_embeddable": true, 
    "source": "https://hvbqwg.dm2302.livefilestore.com/y2m6t-kEOaAd1qXi2n4cvNuVCMqU2Is3Ft_7g7UGM1h6Ib8oyGSFzT70rT3F3mz5PFsrzUDkyAfhYoh1YIZWNY3INmCIKheJpZWoUVTvz-xh5I/Mod%20Permissions.xlsx?psid=1", 
    "link": "https://skydrive.live.com/redir.aspx?cid=a4423f3123801749&page=view&resid=A4423F3123801749!418&parid=A4423F3123801749!129", 
    "type": "file", 
    "shared_with": { 
     "access": "Public" 
    }, 
    "created_time": "2014-01-16T07:06:41+0000", 
    "updated_time": "2014-01-16T07:14:51+0000", 
    "client_updated_time": "2014-01-16T07:14:51+0000" 
} 
+0

您對獲得訪問令牌或有關分析JSON的問題? – 2014-01-16 09:20:53

+0

訪問令牌,抱歉的歧義 –

回答

0

做一個帖子https://login.live.com/oauth20_token.srf轉換您refresh_tokenaccess_token。閱讀更多MS documentation子彈#6。

這裏有一個樣品的node.js代碼

var options,request; 
request = require('request'); 

options = { 
    url: 'https://login.live.com/oauth20_token.srf', 
    form: { 
    client_id: YOUR CLIENT_ID, 
    redirect_uri: YOUR REDIRECT_URI, 
    client_secret: YOUR CLIENT_SECRET, 
    refresh_token: YOUR REFRESH_TOKEN, 
    grant_type: 'refresh_token' 
    }, 
    headers: { 
    'Accept': 'application/json' 
    } 
}; 

request.post(options, function(err, response, data) { 
});