UNPKG

5.17 kBJavaScriptView Raw
1var http = require("http")
2 , authom = require("../lib/authom")
3 , server = http.createServer()
4 , port = process.env.PORT || 80
5
6 , questions = Buffer(
7 "<html>" +
8 "<body style='font: 300% sans-serif'>" +
9 "<div><a href='/auth/37signals'>Who am I on 37Signals?</a></div>" +
10 "<div><a href='/auth/dwolla'>Who am I on Dwolla?</a></div>" +
11 "<div><a href='/auth/github'>Who am I on Github?</a></div>" +
12 "<div><a href='/auth/google'>Who am I on Google?</a></div>" +
13 "<div><a href='/auth/facebook'>Who am I on Facebook?</a></div>" +
14 "<div><a href='/auth/fitbit'>Who am I on Fitbit?</a></div>" +
15 "<div><a href='/auth/foursquare'>Who am I on Foursquare?</a></div>" +
16 "<div><a href='/auth/gowalla'>Who am I on Gowalla?</a></div>" +
17 "<div><a href='/auth/instagram'>Who am I on Instagram?</a></div>" +
18 "<div><a href='/auth/linkedin'>Who am I on LinkedIn?</a></div>" +
19 "<div><a href='/auth/meetup'>Who am I on Meetup?</a></div>" +
20 "<div><a href='/auth/reddit'>Who am I on Reddit?</a></div>" +
21 "<div><a href='/auth/soundcloud'>Who am I on SoundCloud?</a></div>" +
22 "<div><a href='/auth/twitter'>Who am I on Twitter?</a></div>" +
23 "<div><a href='/auth/windowslive'>Who am I on Windows Live?</a></div>" +
24 "<div><a href='/auth/dropbox'>Who am I on Dropbox?</a></div>" +
25 "<div><a href='/auth/bitbucket'>Who am I on Bitbucket?</a></div>" +
26 "<div><a href='/auth/vkontakte'>Who am I on Vkontakte?</a></div>" +
27 "</body>" +
28 "</html>"
29 )
30
31server.on("request", function(req, res) {
32 res.writeHead(200, {
33 "Content-Type": "text/html",
34 "Content-Length": questions.length
35 })
36
37 res.end(questions)
38})
39
40authom.createServer({
41 service: "reddit",
42 id: "hG5c04ZOk0UngQ",
43 secret: "mdJoGP4ayA9M7NdBiKxZUyewz7M",
44 state: "unguessable-random-string"
45})
46
47authom.createServer({
48 service: "github",
49 id: "7e38d12b740a339b2d31",
50 secret: "116e41bd4cd160b7fae2fe8cc79c136a884928c3",
51 state: "unguessable-random-string"
52})
53
54authom.createServer({
55 service: "google",
56 id: "515913292583.apps.googleusercontent.com",
57 secret: "UAjUGd_MD9Bkho-kazmJ5Icm"
58})
59
60authom.createServer({
61 service: "facebook",
62 id: "256546891060909",
63 secret: "e002572fb07423fa66fc38c25c9f49ad",
64 fields: ['name', 'picture']
65})
66
67authom.createServer({
68 service: "foursquare",
69 id: "0DPGLE430Y2LFUCOSFXB0ACG3GGD5DNHH5335FLT4US1QDAZ",
70 secret: "WLNCAVFHCMQGVYOZTNOLPXW0XL2KN0DRD1APOA45SRGEZSGK"
71})
72
73authom.createServer({
74 service: "instagram",
75 id: "e55497d0ebc24289aba4e715f1ab7d2a",
76 secret: "a0e7064bfda64e57a46dcdba48378776"
77})
78
79authom.createServer({
80 service: "meetup",
81 id: "t2glfik2ff9e56ajs560fouf0f",
82 secret: "q103560uihj1sp1dv08ae3ch5v"
83})
84
85authom.createServer({
86 service: "gowalla",
87 id: "b8514b75c2674916b77c9a913783b9c2",
88 secret: "34f713fdd6b4488982328487f443bd6d"
89})
90
91authom.createServer({
92 service: "37signals",
93 id: "c2098292571a03070eb12746353997fb8d6f0e00",
94 secret: "4cb7f46fa83f73ec99d37162b946522b9e7a4d5a"
95})
96
97authom.createServer({
98 service: "soundcloud",
99 id: "9e5e7b0a891b4a2b13aeae9e5b0c89bb",
100 secret: "2f4df63c8ff10f466685c305e87eba6f"
101})
102
103authom.createServer({
104 service: "windowslive",
105 id: "000000004C06BA3A",
106 secret: "2RsIhweMq6PxR8jc5CjTVoCqTvKZmctY",
107 scope: "wl.basic"
108})
109
110authom.createServer({
111 service: "dwolla",
112 id: "0vNUP/9/GSBXEv69nqKZVfhSZbw8XQdnDiatyXSTM7vW1WzAAU",
113 secret: "KI2tdLiRZ813aclUxTgUVyDbxysoJQzPBjHTJ111nHMNdAVlcs",
114 scope:"AccountInfoFull"
115})
116
117authom.createServer({
118 service: "twitter",
119 id: "LwjCfHAugMghuYtHLS9Ugw",
120 secret: "etam3XHqDSDPceyHti6tRQGoywiISY0vZWfzhQUxGL4"
121})
122
123authom.createServer({
124 service: "linkedin",
125 id: "bc8kg8qo87z6",
126 secret: "0azYQoOJ9vF8i7mC"
127})
128
129authom.createServer({
130 service: "fitbit",
131 id: "45987d27b0e14780bb1a6f1769e679dd",
132 secret: "3d403aaeb5b84bc49e98ef8b946a19d5"
133})
134
135authom.createServer({
136 service: "dropbox",
137 id: "zuuteb2w7i82mdg",
138 secret: "rj503lgqodxzvbp",
139 info: false
140})
141
142authom.createServer({
143 service: "bitbucket",
144 id: "2sD26teP8SVfStUwMd",
145 secret: "vTeXLmyXubwFkrBAP96KRjgT8tubVqpD",
146 emails: false
147})
148
149authom.createServer({
150 service: "vkontakte",
151 id: "3793488",
152 secret: "jZnIeU4nnQfqM5mfjkK0",
153 fields: ['screen_name', 'sex', 'photo']
154})
155
156authom.on("auth", function(req, res, data) {
157 var answer = Buffer(
158 "<html>" +
159 "<body>" +
160 "<div style='font: 300% sans-serif'>You are " + data.id + " on " + data.service + ".</div>" +
161 "<pre><code>" + JSON.stringify(data, null, 2) + "</code></pre>" +
162 "</body>" +
163 "</html>"
164 )
165
166 res.writeHead(200, {
167 "Content-Type": "text/html; charset=utf-8",
168 "Content-Length": answer.length
169 })
170
171 res.end(answer)
172})
173
174authom.on("error", function(req, res, data){
175 data = Buffer("An error occurred: " + JSON.stringify(data))
176
177 res.writeHead(500, {
178 "Content-Type": "text/plain; charset=utf-8",
179 "Content-Length": data.length
180 })
181
182 res.end(data)
183})
184
185authom.listen(server)
186server.listen(port, function() {
187 console.log("listening at http://authom.jedschmidt.com/")
188})