首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用iron-ajax使用API令牌对freshDesk进行身份验证

使用iron-ajax使用API令牌对freshDesk进行身份验证
EN

Stack Overflow用户
提问于 2016-06-14 23:32:28
回答 1查看 209关注 0票数 1

在所有示例中,documentation here都显示了它们使用curl进行身份验证。还有针对各种语言的some examples here。但是,我正在尝试将API与polymeriron-ajax元素一起使用,但在进行身份验证时遇到了问题。

我尝试基于他们的nodejs示例并将其包含在params中,但它仍然不起作用。

代码语言:javascript
复制
<template is="dom-bind" id="app">
    <iron-ajax auto
               url="https://<mydomain>.freshdesk.com/api/v2/tickets"
               params='{ "user": "<myapitoken>", "pass": "X", "sendImmediately": "true" }'
               handle-as="json"
               last-response="{{ajaxResponse}}"></iron-ajax>

    <template is="dom-repeat" items="[[ajaxResponse.items]]">
        <mhc-ticket ticket-id="[[item.id]]"></mhc-ticket>
    </template>

</template>

我只是得到了一个401 (Unauthorized)。我该如何进行身份验证?

EN

回答 1

Stack Overflow用户

发布于 2016-06-14 23:55:58

我必须将参数移动到标头,将with-credentials设置为true,并强制method为"GET“。它现在起作用了:

代码语言:javascript
复制
<template is="dom-bind" id="app">
    <iron-ajax auto
               url="https://<mydomain>.freshdesk.com/api/v2/tickets"
               headers='{ "user": "<myapikey>", "pass": "X", "sendImmediately": "true" }'
               handle-as="json"
               method="GET"
               last-response="{{ajaxResponse}}"
               with-credentials></iron-ajax>

    <template is="dom-repeat" items="[[ajaxResponse.items]]">
        <mhc-ticket ticket-id="[[item.id]]"></mhc-ticket>
    </template>

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

https://stackoverflow.com/questions/37816344

复制
相关文章

相似问题

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