【问题标题】:Using the access token with the SkyDrive API将访问令牌与 SkyDrive API 一起使用
【发布时间】:2014-02-05 02:41:47
【问题描述】:

我一直在尝试通过以下链接访问 json 结果:

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"
}

【问题讨论】:

  • 您的问题是关于获取访问令牌还是关于解析 JSON?
  • 访问令牌,有歧义见谅

标签: api access-token onedrive


【解决方案1】:

https://login.live.com/oauth20_token.srf 发帖,将您的refresh_token 转换为access_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) {
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    • 2020-11-27
    • 2017-11-13
    • 2011-10-02
    • 1970-01-01
    • 2012-10-02
    • 1970-01-01
    相关资源
    最近更新 更多