首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Trello api无效令牌

Trello api无效令牌
EN

Stack Overflow用户
提问于 2016-11-12 18:25:33
回答 1查看 1.3K关注 0票数 0

我不得不使用trello API,但我收到了错误400 (无效令牌),我不知道为什么。

这是我的代码(我已经用mykey替换了我的实际密钥)

代码语言:javascript
复制
<html>
  <head>
    <title>A Trello Dashboard</title>
    <link rel="stylesheet" media="screen" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  </head>
  <body>
    <div class="container">
      <h1>Trello Dashboard</h1>
    </div> 
  </body>    

  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script src="https://trello.com/1/client.js?key=mykey"></script>

  <script type="text/javascript"> 
    Trello.authorize({
      type: 'popup',
      name: 'A Trello Dashboard',
      scope: {
        read: 'true',
        write: 'true' 
      },
      expiration: 'never',
      success: function() { console.log("Successful authentication"); },
      error: function() { console.log("Failed authentication"); }
    });
  </script>
</html>
EN

回答 1

Stack Overflow用户

发布于 2016-11-13 05:38:37

您应该将所有代码逻辑放在document.ready中,这样整个文档就准备好了,然后只有您才会看到用于身份验证/授权的弹出窗口。你可以在这里获得一个有效的应用密钥:https://trello.com/app-key参见代码示例:

代码语言:javascript
复制
<html>
  <head>
    <title>A Trello Dashboard</title>
    <link rel="stylesheet" media="screen" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  </head>
  <body>
    <div class="container">
      <h1>Trello Dashboard</h1>
    </div> 
    <div id="loggedin">
    <div id="header">
        Logged in to as <span id="fullName"></span> 
    </div>

    <div id="output"></div>
</div>    

  </body>    

  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script src="https://api.trello.com/1/client.js?key=[appKeygoeshere]"></script>

  <script type="text/javascript"> 
  $(window).load(function(){
    Trello.authorize({
      type: 'popup',
      name: 'A Trello Dashboard',
      scope: {
        read: 'true',
        write: 'true' 
      },
      expiration: 'never',
      success: function() { console.log("Successful authentication");
          Trello.members.get("me", function(member){
            $("#fullName").text(member.fullName);

            var $cards = $("<div>")
                .text("Loading Cards...")
                .appendTo("#output");

            // Output a list of all of the cards that the member 
            // is assigned to
            Trello.get("members/senthil192/cards/all", function(cards) {
                $cards.empty();
                $.each(cards, function(ix, card) {
                    //alert(card.name);
                    $("<a>")
                    .attr({href: card.url, target: "trello"})
                    .addClass("card")
                    .text(card.name)
                    .appendTo($cards);
                });  
            });
        });
      },
      error: function() { console.log("Failed authentication"); }
    });
    });

  </script>

</html>

代码引用url:http://jsfiddle.net/danlec/nNesx/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40561881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档