2013-06-18 2 views

答えて

49

あなたは2のいずれかの方法でこれを行うことができます -

直接下記のアドレスへのユーザー。これにより、コピーして貼り付けられるトークンを持つページにユーザーが誘導されます。重要なビットは、あなたがexpiration = neverscope = read,write

https://trello.com/1/authorize?key=substitutewithyourapplicationkey&scope=read%2Cwrite&name=My+Application&expiration=never&response_type=token 

を依頼するか、アクセストークンの要求を自動化する(難しい)のOAuthを使用することです。詳しくはdocumentationをご覧ください。

トークンを取得したら、必要なAPI呼び出しを行うことができます。

+1

docsページへのリンク:https://trello.com/docs/gettingstarted/index.html#getting-a-token-from-a-user –

10

サーバー側のすべてを実行する必要がある場合、Andy Jonesは正しいですが、それらは唯一の2つの方法です。

リダイレクションをサーバー側で行うのではなく、javascript + jqueryコードを書くことができれば、Trelloのclient.jsラッパーを利用することができます。これはAndyの説明とまったく同じですが、あなたのためにそのほとんどを処理しますが、これは便利な方法です。

また、私が最近発見したように、サーバーサイドの処理が必要な場合でも、おそらくclient.jsを使用して、auth successハンドラでTrello.token()を使用してトークンを取得し、それをサーバー側のコードに追加します。それは次のようになります。

// include whatever version of jquery you want to use first 
<script src="https://api.trello.com/1/client.js?key=[your application key]" type="text/javascript"></script> 

// call this whenever you want to make sure Trello is authenticated, and get a key. 
// I don't call it until the user needs to push something to Trello, 
// but you could call it in document.ready if that made more sense in your case. 
function AuthenticateTrello() { 
     Trello.authorize({ 
      name: "your project name", 
      type: "popup", 
      interactive: true, 
      expiration: "never", 
      success: function() { onAuthorizeSuccessful(); }, 
      error: function() { onFailedAuthorization(); }, 
      scope: { write: true, read: true }, 
     }); 
} 

function onAuthorizeSuccessful() { 
    var token = Trello.token(); 
    // whatever you want to do with your token. 
    // if you can do everything client-side, there are other wrapper functions 
    // so you never need to use the token directly if you don't want to. 
} 

function onFailedAuthorization() { 
    // whatever 
} 
+0

これは非常に便利です。どうもありがとうございます。 – Lokesh

0

あなただけがあなたがhere以上ログインされているに基づいてapp-keysecrettokenを得ることができます個人的な使用のためのトークンが必要な場合。

関連する問題