diff --git a/oauth3.core.js b/oauth3.core.js index 3cb6a7b..b5284de 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -1065,7 +1065,7 @@ // this is not necessary, but it's relatively small // and gives people the 3-line examples they love so much - OAUTH3.create = function (location/*, opts*/) { + OAUTH3.create = function (location, opts) { if (!location) { location = OAUTH3._browser.window.location; } @@ -1073,16 +1073,29 @@ var result = { _clientUri: OAUTH3.clientUri(location) , _providerUri: null - , init: function (location) { + , _init: function (location, opts) { + var me = this; + if (location) { + me._clientUri = OAUTH3.clientUri(location); + } + if (opts) { + if (opts.providerUri) { + me._providerUri = opts.providerUri; + } + if (opts.session) { + me.session(opts.session, opts.sessionId); + } + } + } + , init: function (location/*, opts*/) { var me = this; var p = OAUTH3.PromiseA.resolve(); - if (location) { - this._clientUri = OAUTH3.clientUri(location); - } - if (this._providerUri) { + me._init(location, opts); + + if (me._providerUri) { // returns directives - p = OAUTH3.discover(this._providerUri, { client_id: this._clientUri }); + p = OAUTH3.discover(me._providerUri, { client_id: this._clientUri }); } return p.then(function () { @@ -1158,6 +1171,9 @@ result.authenticate = result.login; result.authorize = result.login; result.expire = result.logout; + + result._init(location, opts); + return result; };