Использование библиотеки client.js для API Trello

Я новичок в API Trello. Как предложил Trello, я пытаюсь использовать библиотеку client.js. Я следовал инструкциям, и я получаю сообщение «Успешная аутентификация» в консоли, но все же я получаю ошибку 401 (в консоли):

POST https://api.trello.com/1/cards 401 ()            jquery-1.7.1.min.js:4 

Вот мой код:

 <head>
    <title>Trello api</title>

 <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
 <script src="https://api.trello.com/1/client.js?    
  key=[my key]"></script>
</head>
<body>
   <script>
      var authenticationSuccess = function() { console.log('Successful  
      authentication'); };
      var authenticationFailure = function() { console.log('Failed    
      authentication'); };

Trello.authorize({
      type: 'popup',
      name: 'Getting Started Application',
      scope: {
      read: true,
      write: true },
      expiration: 'never',
      success: authenticationSuccess,
      error: authenticationFailure
      });


var myList = 'my list';
var creationSuccess = function(data) {
       console.log('Card created successfully. Data returned:' +   
       JSON.stringify(data));
};
var newCard = {
       name: 'New Test Card', 
       desc: 'This is the description of our new card.',
       idList: myList,
       pos: 'top'
       };
  Trello.post("cards", newCard, creationSuccess);


  </script>

Есть идеи? Спасибо.


person Tzvibe    schedule 10.04.2016    source источник


Ответы (1)


Я была такая же проблема. Я беру «логин» и «выход» из http://jsfiddle.net/A3Xgk/2/. , и это работает.

Trello.authorize({
    interactive: false,
    success: onAuthorize
});

$("#connectLink").click(function() {
    Trello.authorize({
        type: "popup",
        success: onAuthorize
    });
});

Если не поможет, напишите мне, я даю вам свой код.

person Анастасия Норцо&    schedule 11.08.2016