Polymer 使用iron ajax向freshDesk使用API令牌进行身份验证
显示了在所有示例中使用Polymer 使用iron ajax向freshDesk使用API令牌进行身份验证,polymer,ajax,authentication,Polymer,Ajax,Authentication,显示了在所有示例中使用curl进行身份验证。对于各种语言也有不同的解释。然而,我试图将API与’siron ajax元素一起使用,我在身份验证方面遇到了问题 我试着以他们的nodejs样本为基础,将其包含在params中,但仍然不起作用 <template is="dom-bind" id="app"> <iron-ajax auto url="https://<mydomain>.freshdesk.com/api/v2/ti
curl
进行身份验证。对于各种语言也有不同的解释。然而,我试图将API与’siron ajax
元素一起使用,我在身份验证方面遇到了问题
我试着以他们的nodejs样本为基础,将其包含在params中,但仍然不起作用
<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(未经授权)
。我应该如何进行身份验证?我必须将参数移动到标题,将带有凭据的设置为true,并强制方法
为“GET”。它现在可以工作了:
<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>