Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to pass parameters to the authorize path. #99

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implemented possibility that allows to pass params to the authorize p…
…ath.
André König committed Oct 11, 2011

Verified

This commit was signed with the committer’s verified signature.
shikokuchuo Charlie Gao
commit 9f0250a568c6355139e4635ba8016359b465715c
14 changes: 13 additions & 1 deletion lib/modules/oauth.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ everyModule.submodule('oauth')
, requestTokenPath: "the path on the OAuth provider's domain where we request the request token, e.g., /oauth/request_token"
, accessTokenPath: "the path on the OAuth provider's domain where we request the access token, e.g., /oauth/access_token"
, authorizePath: 'the path on the OAuth provider where you direct a visitor to login, e.g., /oauth/authorize'
, authorizeParams: 'the params which will be appended to the authorizePath (e.g. force_login).'
, sendCallbackWithAuthorize: 'whether you want oauth_callback=... as a query param send with your request to /oauth/authorize'
, consumerKey: 'the api key provided by the OAuth provider'
, consumerSecret: 'the api secret provided by the OAuth provider'
@@ -120,7 +121,18 @@ everyModule.submodule('oauth')
// module needs it as a uri query parameter. However, in cases such as twitter, it allows you to over-ride
// the callback url settings at dev.twitter.com from one place, your app code, rather than in two places -- i.e.,
// your app code + dev.twitter.com app settings.
var redirectTo = this._oauthHost + this._authorizePath + '?oauth_token=' + token;
var params = this._authorizeParams;
var querystring = '?';

if (params) {
for(var key in params) {
if(params.hasOwnProperty(key)) {
querystring += key + '=' + params[key] + '&';
}
}
}

var redirectTo = this._oauthHost + this._authorizePath + querystring + 'oauth_token=' + token;
if (this._sendCallbackWithAuthorize) {
redirectTo += '&oauth_callback=' + this._myHostname + this._callbackPath;
}