Skip to content

Instantly share code, notes, and snippets.

@fruchtose
Created November 22, 2012 22:19
Show Gist options
  • Save fruchtose/4133131 to your computer and use it in GitHub Desktop.
Save fruchtose/4133131 to your computer and use it in GitHub Desktop.
Everyauth OAuth 1.0a configuration metaprogramming
everyModule.submodule('oauth')
.configurable({
apiHost: 'e.g., https://api.twitter.com'
, oauthHost: 'the host for the OAuth provider'
, 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'
, 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'
, myHostname: 'e.g., http://localhost:3000 . Notice no trailing slash'
, alwaysDetectHostname: 'does not cache myHostname once. Instead, re-detect it on every request. Good for multiple subdomain architectures'
, redirectPath: 'Where to redirect to after a failed or successful OAuth authorization'
, convertErr: '(DEPRECATED) a function (data) that extracts an error message from data arg, where `data` is what is returned from a failed OAuth request'
, authCallbackDidErr: 'Define the condition for the auth module determining if the auth callback url denotes a failure. Returns true/false.'
})
.definit( function () {
this.oauth = new OAuth(
this.oauthHost() + this.requestTokenPath()
, this.oauthHost() + this.accessTokenPath()
, this.consumerKey()
, this.consumerSecret()
, '1.0', null, 'HMAC-SHA1');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment