UNPKG

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