我正在使用 Polymerfire 进行身份验证。来自谷歌 REST API 的响应是 401...
您可以使用 Iron-ajax 发出 Google api 请求吗?它在 oauth 操场上效果很好......
代码:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../bower_components/iron-image/iron-image.html">
<link rel="import" href="../bower_components/iron-list/iron-list.html">
<link rel="import" href="../bower_components/google-apis/google-apis.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="shared-styles.html">
<dom-module id="doc-create">
<template>
<style include="shared-styles">
:host {
display: block;
padding: 10px;
}
</style>
<!--
<iron-ajax
auto
url="https://api.github.com/repos/firebase/polymerfire/issues"
handle-as="json"
params="{state: "closed", page: "1"}"
last-response="{{ajaxResponse}}"></iron-ajax> -->
<iron-ajax
auto
url="https://www.googleapis.com/drive/v3/about"
params = "{{ajaxParams}}"
handle-as="json"
with-credentials
last-response="{{ajaxResponse}}"></iron-ajax>
<div class="card">
<template is="dom-repeat" items="[[ajaxResponse]]">
<div class="horizontal-section">
<p>[[index]]: [[item.title]]</p>
</div>
</template>
</div>
<div class="card">
Response Data: [[ajaxResponse]]
Params: [[ajaxParams.fields]]
</div>
</template>
<script>
Polymer({
is: 'doc-create',
properties: {
fields: {
type: String,
value: 'user'
},
apikey: {
type: String,
value: 'ya29.CjBVA-xV9TJ9cS25hx9qJvEgD1w'
},
ajaxParams: {
type: String,
computed: 'processParams(fields, apikey)'
}
},
processParams: function(fields, apikey) {
return {
fields: fields,
key: apikey
};
}
// ,
// ready: function(){
// var request = api.url.get({
// shortUrl: 'oo.gl/fbsS'
// });
// request.execute(function(resp) {
// console.log(resp);
// });
// }
});
</script>
</dom-module>
我究竟做错了什么??? 控制台截图