Skip to content

Commit 02b4080

Browse files
committed
toJson when OAuth.create (Fix #67, Closes #68)
1 parent 069051a commit 02b4080

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oauth-js",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"main": "dist/oauth.min.js",
55
"description": "OAuth that just works",
66
"license": "Apache-2.0",

coffee/lib/oauth.coffee

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ module.exports = (Materia) ->
5252
res = {}
5353
for i of tokens
5454
res[i] = tokens[i]
55+
56+
res.toJson = ->
57+
a = {}
58+
a.access_token = res.access_token if res.access_token?
59+
a.oauth_token = res.oauth_token if res.oauth_token?
60+
a.oauth_token_secret = res.oauth_token_secret if res.oauth_token_secret?
61+
a.expires_in = res.expires_in if res.expires_in?
62+
a.token_type = res.token_type if res.token_type?
63+
a.id_token = res.id_token if res.id_token?
64+
a.provider = res.provider if res.provider?
65+
a.email = res.email if res.email?
66+
return a
67+
5568
res.get = make_res("GET")
5669
res.post = make_res("POST")
5770
res.put = make_res("PUT")

dist/oauth.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
module.exports = {
33
oauthd_url: "https://oauth.io",
44
oauthd_api: "https://oauth.io/api",
5-
version: "web-0.4.4",
5+
version: "web-0.4.5",
66
options: {}
77
};
88

@@ -198,6 +198,35 @@ module.exports = function(Materia) {
198198
for (i in tokens) {
199199
res[i] = tokens[i];
200200
}
201+
res.toJson = function() {
202+
var a;
203+
a = {};
204+
if (res.access_token != null) {
205+
a.access_token = res.access_token;
206+
}
207+
if (res.oauth_token != null) {
208+
a.oauth_token = res.oauth_token;
209+
}
210+
if (res.oauth_token_secret != null) {
211+
a.oauth_token_secret = res.oauth_token_secret;
212+
}
213+
if (res.expires_in != null) {
214+
a.expires_in = res.expires_in;
215+
}
216+
if (res.token_type != null) {
217+
a.token_type = res.token_type;
218+
}
219+
if (res.id_token != null) {
220+
a.id_token = res.id_token;
221+
}
222+
if (res.provider != null) {
223+
a.provider = res.provider;
224+
}
225+
if (res.email != null) {
226+
a.email = res.email;
227+
}
228+
return a;
229+
};
201230
res.get = make_res("GET");
202231
res.post = make_res("POST");
203232
res.put = make_res("PUT");

dist/oauth.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oauthio-web",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "OAuth that just works",
55
"main": "dist/oauth.min.js",
66
"repository": {

0 commit comments

Comments
 (0)