-
Notifications
You must be signed in to change notification settings - Fork 0
/
Google-Refresh.json
120 lines (120 loc) · 3.38 KB
/
Google-Refresh.json
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
[
{
"id": "1b40ef83a0652010",
"type": "subflow",
"name": "Oauth2 Refresh",
"info": "",
"category": "Google API",
"in": [
{
"x": 240,
"y": 80,
"wires": [
{
"id": "ae3bb5af57217834"
}
]
}
],
"out": [
{
"x": 940,
"y": 80,
"wires": [
{
"id": "89eff7bbb77b98c4",
"port": 0
}
]
}
],
"env": [
{
"name": "Client_id",
"type": "cred",
"ui": {
"icon": "font-awesome/fa-lock"
}
},
{
"name": "Secret",
"type": "cred",
"ui": {
"icon": "font-awesome/fa-lock"
}
}
],
"meta": {},
"color": "#C0DEED",
"icon": "font-awesome/fa-lock"
},
{
"id": "ae3bb5af57217834",
"type": "function",
"z": "1b40ef83a0652010",
"name": "Refresh Token",
"func": "var Google_refresh = global.get('Google_refresh');\n\nmsg.payload ={\n \"grant_type\": \"refresh_token\",\n \"client_id\": env.get(\"Client_id\"),\n \"client_secret\": env.get(\"Secret\"),\n \"refresh_token\": Google_refresh\n }\n\nmsg.headers = {};\nmsg.headers['Accept'] = \"application/json\";\nmsg.headers['content-type'] = 'application/json';\nmsg.headers['Cache-Control'] = 'no-cache';\n\nmsg.method = \"POST\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 80,
"wires": [
[
"be36287ea0b3eb53"
]
]
},
{
"id": "be36287ea0b3eb53",
"type": "http request",
"z": "1b40ef83a0652010",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://oauth2.googleapis.com/token",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 570,
"y": 80,
"wires": [
[
"89eff7bbb77b98c4"
]
]
},
{
"id": "89eff7bbb77b98c4",
"type": "function",
"z": "1b40ef83a0652010",
"name": "Save OAuth Tokens",
"func": "if (msg.payload.access_token) {\n global.set('Google_token', msg.payload.access_token);\n //global.set('Google_refresh', msg.payload.refresh_token);\n Time = new Date()\n msg.payload = \"Google Access Granted \" + Time;\n \n} else {\n msg.payload = \"Google Authorization error.\";\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 80,
"wires": [
[]
]
},
{
"id": "5f43723c3facbe59",
"type": "subflow:1b40ef83a0652010",
"z": "c47e314473c912ae",
"name": "",
"x": 240,
"y": 180,
"wires": [
[]
]
}
]