Skip to content

Commit 6b1c089

Browse files
committed
Added proxyUrl property to the options as work-around for JavaScript’s same-domain policy.
If you have setup http://foo.org/bar as proxy for http://bar.org then you can serve a script file from foo.org and issue an oauth request to bar.org like this: var oauth = OAuth({ proxyUrl: 'http://foo.org/bar', consumerKey: '...', consumerSecret: '...' }); oauth.get('http://bar.org/oauth/request_token', function() { /* ... */ }); Also works with https URLs. (But remember to enable SSLProxyEngine if you are using Apache!)
1 parent a4f813d commit 6b1c089

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/OAuth/Consumer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
var oauth = {
2626
enablePrivilege: options.enablePrivilege || false,
2727

28+
proxyUrl: options.proxyUrl,
2829
callbackUrl: options.callbackUrl || 'oob',
2930

3031
consumerKey: options.consumerKey,
@@ -197,6 +198,10 @@
197198
{
198199
headerParams['realm'] = this.realm;
199200
}
201+
202+
if (oauth.proxyUrl) {
203+
url = URI(oauth.proxyUrl + url.path);
204+
}
200205

201206
if(appendQueryString || method == 'GET') {
202207
url.query.setQueryParams(data);

0 commit comments

Comments
 (0)