【问题标题】:How can I retrieve a token from Trello API如何从 Trello API 检索令牌
【发布时间】:2017-01-09 20:27:02
【问题描述】:

我正在构建一个应用程序,要求用户授权该应用程序使用他的 Trello 帐户。

首先,我使用我的开发人员密钥(由 Trello 提供)并执行 API 调用,如下所示:

Trello.authorize({
    type: 'popup',
    name: 'My App',
    persist: 'true', // the token will be saved on localstorage
    scope: {
        read: 'true',
        write: 'true' 
    },
    expiration: 'never',
    success: authenticationSuccess,
    error: authenticationFailure
});

这会显示一个弹出窗口,要求用户允许(授权)。

我的问题是,我怎样才能在这个请求中获得令牌?此方法不提供任何响应。

我发现获取令牌的唯一方法是:将用户发送到...

https://trello.com/1/connect?key=my_developer_key&name=My+App&response_type=token&scope=read,write

但是,用户进入一个空白页面,显示:

“您已授权访问您的 Trello 信息。” “要完成这个过程,请给出这个令牌:” “21265656542121245...某个令牌”

我不希望用户需要给我任何令牌。

谁能帮我解决这个问题?谢谢

【问题讨论】:

    标签: javascript node.js rest token trello


    【解决方案1】:

    在 Angular 中,由于 authOpts 中的 persist = true(默认),我能够在成功验证后使用 localStorage.getItem('trello_token') 从本地存储访问令牌。

    【讨论】:

      【解决方案2】:

      authenticationSuccess,您将能够查看localStorage

      localStorage.trello_token
      

      希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-22
        • 2019-07-29
        • 2021-11-04
        • 2015-10-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多