-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth-v1.html
86 lines (76 loc) · 1.56 KB
/
oauth-v1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../oauth-popup/oauth-popup.html">
<dom-module id="oauth-v1">
<style>
:host {
display: none;
}
</style>
<template>
<oauth-popup id="popup"
width="{{popupWidth}}" height="{{popupHeight}}"
url="{{url}}" response="{{response}}">
</oauth-popup>
<iron-ajax id="exchange" method="GET" url="{{exchange_url}}" params="{{query}}"
handle-as="json" last-response="{{token}}">
</iron-ajax>
</template>
</dom-module>
<script>
Polymer({
is: 'oauth-v1',
properties: {
name: {
type: String
},
display: {
type: String,
value: 'popup'
},
endpoint: {
type: String
},
url: {
type: String
},
redirect_uri: {
type: String
},
popupWidth: {
type: Number
},
popupHeight: {
type: Number
},
response: {
type: Object,
notify: true,
observer: 'on_response'
},
exchange_url: {
type: String
},
query: {
type: Object
},
token: {
type: Object,
observer: 'on_token'
}
},
open: function () {
this.url = this.endpoint;
this.$.popup.open();
},
on_response: function (response) {
this._exchange();
},
_exchange: function () {
this.query = this.response;
this.$.exchange.generateRequest();
},
on_token: function () {
console.log(this.token);
}
});
</script>