get issuer via rpc
This commit is contained in:
parent
18170e94f4
commit
39c0c775ed
|
@ -747,6 +747,20 @@
|
|||
*/
|
||||
return OAUTH3._browser.request(preq, opts);
|
||||
}
|
||||
, issuer: function (opts) {
|
||||
if (!opts) { opts = {}; }
|
||||
|
||||
// TODO this will default to browserlogin.org
|
||||
var broker = opts.broker || 'https://broker.oauth3.org';
|
||||
|
||||
opts._rpc = "broker";
|
||||
opts._scheme = "localstorage:";
|
||||
opts._pathname = "issuer";
|
||||
|
||||
return OAUTH3._rpcHelper(broker, opts).then(function(issuer) {
|
||||
return issuer;
|
||||
});
|
||||
}
|
||||
, implicitGrant: function (directives, opts) {
|
||||
var promise;
|
||||
var providerUri = directives.azp || directives.issuer || directives;
|
||||
|
@ -923,13 +937,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!(opts.client_id || opts.client_uri).match(OAUTH3._browser.window.location.hostname)) {
|
||||
if (!(opts.client_id || opts.client_uri || '').match(OAUTH3._browser.window.location.hostname)) {
|
||||
console.warn("It looks like your client_id doesn't match your current window..."
|
||||
+ " this probably won't end well");
|
||||
console.warn(opts.client_id || opts.client_uri, OAUTH3._browser.window.location.hostname);
|
||||
}
|
||||
|
||||
var discReq = OAUTH3.urls.rpc(
|
||||
var discReq = OAUTH3.urls[opts._rpc || 'rpc'](
|
||||
providerUri
|
||||
, { client_id: (opts.client_id || opts.client_uri || OAUTH3.clientUri(OAUTH3._browser.window.location))
|
||||
, windowType: opts.broker && opts.windowType || 'background'
|
||||
|
@ -971,7 +985,14 @@
|
|||
}
|
||||
|
||||
// TODO params should have response_type indicating json, binary, etc
|
||||
var result = JSON.parse(OAUTH3._base64.decodeUrlSafe(params.data || params.result || params.directives));
|
||||
var result;
|
||||
try {
|
||||
result = JSON.parse(OAUTH3._base64.decodeUrlSafe(params.data || params.result || params.directives));
|
||||
} catch(e) {
|
||||
result = params.data || params.result;
|
||||
}
|
||||
|
||||
console.log('result:', result);
|
||||
// caller will call OAUTH3.hooks.directives.set(providerUri, directives);
|
||||
return result;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue