2
votes

I have been trying to get access to the json result with the following link:

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

But as you can see by clicking on it yourself, you need an access token. I already have an access token, but it only lasts for 3600 seconds (1 hour).

Is there a way to get the results of the link (the json shown below) without the access token expiring? I know there is a refresh token, but I am unsure how to use it.

{
   "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"
}
1
Is your question about getting the access token or about parsing JSON?user1907906
The access token, sorry for the ambiguityAndrew Wong

1 Answers

0
votes

Do a post to https://login.live.com/oauth20_token.srf to convert your refresh_token to an access_token. Read more in MS documentation bullet #6.

Here are a sample node.js code

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) {
});