使用HelloJS向Tumblr API发出OAuth 1.0a签名请求时遇到问题

诺亚

我正在尝试与Tumblr API交互以获取关注者列表。我是整个OAuth的新手,所以我尝试通过https://adodson.com/hello.js/demos/tumblr.html上的演示对电话进行建模不幸的是,他们给出的示例仅需要用于识别的API密钥(https://www.tumblr.com/docs/en/api/v2#posts),在获取跟随者时,需要经过签名的OAuth请求(https:// www .tumblr.com / docs / en / api / v2#followers)。

我正在使用的电话是:

function getFollowers(blog){
  hello('tumblr').api('blog/'+blog+'/followers/').then(function(r){
    console.log("r", r);
    //Bellow here not really relevant
    var a = r.data.map(function(item){
      return "<h2>"+item.title+"</h2>"+item.body_abstract;
    });
    document.getElementById('blogs').innerHTML = a.join('');
  });
}

这将从代理生成请求URL:

https://auth-server.herokuapp.com/proxy?path=https%3A%2F%2Fapi.tumblr.com%2Fv2%2Fblog%2Fnmlapp.tumblr.com%2Ffollowers%2F%3Fapi_key%3DREDACTED08u%26callback%3D_hellojs_9kvqxi31&access_token=&then=redirect&method=get&suppress_response_codes=truee

和Tumblr的API返回

_hellojs_9kvqxi31({"meta":{"status":401,"msg":"Not Authorized"},"response":[]});

我可以看到该登录调用在“查询字符串参数”字段中具有所有OAuth信息,而我尝试创建的却没有,但是我不确定通过helloJS包含哪种正确的方法。

诺亚

知道了,该功能必须包装在login方法中。这在另一个示例中得到了展示,但是它从api对象中调用参数的方式使我感到困惑。

function doTheThing(network){
hello( network ).login({force:false}).then( function(r){

  hello('tumblr').api('followers').then(function(r){
    console.log("r", r);

    var a = r.data.map(function(item){
      return "<h2>"+item.title+"</h2>"+item.body_abstract;
    });
    document.getElementById('blogs').innerHTML = a.join('');
  });
  });
  }

//...
tumblr:{
 get: {
   //...
   //This next part needs to be generated dynamically, but you get the idea
    'followers': 'blog/BLOGNAME.tumblr.com/followers',
      }

      callback(p.path);
    }
  },

  post: {
    //...
    'followers': function(p, callback) {
      p.path = 'followers';
      query(p, callback);
    }
  },

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用OAuth 1发出Yahoo Weather API请求

如何从Google Cloud获取OAuth2身份验证令牌(代号为1),然后使用它向云自然语言API发出请求

如何使用Scribe通过POST向自定义API发出OAuth2授权请求

向Twitter API发出HTTP请求时未定义的方法“ OAuth”

从ADF和Postman向持久性功能(Azure Functions的扩展)发出后期处理请求时遇到问题

etsy-api-oauth1 PUT 请求在使用 python 时返回无效签名,而不是来自 Postman

在 oAuth Google Api Flow..gDrive 中使用“create_delegated”时遇到问题

使用python向RESTful API发出请求

我在使用 Intersection Observer API 时遇到问题

ECONNRREFUSED 使用 Nodejs 向 API 发出获取请求时出错

无法从 reactjs 中的 axios 为 id=1 文章向 django REST API 后端发出 GET 请求

使用AFNetWorking发送请求时遇到问题

使用Python请求打开页面时遇到问题

向OAuth2访问令牌发出Ajax请求时发生CORS问题

Python-如何使用请求向API发出PATCH请求

使用go向mojang API发出请求会得到403

如何使用Angular向API网关发出Get请求?

使用Laravel向一个API发出多个请求

如何使用restapi向Github存储库发出api请求?

InvalidURIError使用Ruby向Facebook Graph API发出请求

使用OpenAPI 3.0,AWS-Cognito OAuth2配置Springboot时遇到问题

向Fantom中的OAuth 2.0发出POST请求

在oauth进程中从Sonos api发出请求令牌

如何连续向API发出GET请求?

Ajax向API发出多个请求

如何优化向API发出请求的for循环?

如何向zomato api发出cURL请求?

我如何向API发出请求

如何从getStaticProps向API路由发出请求