Skip to content

Instantly share code, notes, and snippets.

@fruchtose
fruchtose / oauthCallbackSequence.js
Created November 22, 2012 07:35
Everyauth OAuth 1.0a authorization callback sequence
everyModule.submodule('oauth')
// .
// .
// .
.get('callbackPath',
'the callback path that the 3rd party OAuth provider redirects to after an OAuth authorization result - e.g., "/auth/twitter/callback"')
.step('extractTokenAndVerifier')
.description('extracts the request token and verifier from the url query')
.accepts('req res next')
.promises('requestToken verifier')
@fruchtose
fruchtose / meetup.js
Created November 22, 2012 07:50
Meetup authorization submodule in Everyauth
var oauthModule = require('./oauth2')
, querystring= require('querystring');
var meetup = module.exports =
oauthModule.submodule('meetup')
.oauthHost('https://secure.meetup.com')
.apiHost('https://api.meetup.com/2')
.entryPath('/auth/meetup')
@fruchtose
fruchtose / MeetupGetter.java
Created November 22, 2012 19:15
Everyauth Meetup Java Analogue
import com.github.bnoguchi.everyauth.*;
import com.github.bnoguchi.everyauth.modules.OAuthSubmodule;
public class MeetupGetter {
public static final Submodule MEETUP;
static {
MEETUP = OAuthSubmodule.submodule("Meetup")
.setOAuthHost("https://secure.meetup.com")
@fruchtose
fruchtose / meetup.js
Created November 22, 2012 19:29
Everyauth Meetup Backbone Analogue
// Initialization style 1
var meetup = new Everyauth.OAuth({
name: 'meetup',
oauthHost: 'https://secure.meetup.com',
apiHost: 'https://api.meetup.com/2',
accessTokenParams: {
grant_type: 'authorization_code'
},
// etc.
});
@fruchtose
fruchtose / oauth.js
Created November 22, 2012 22:19
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'
@fruchtose
fruchtose / everymoduleStep.js
Created November 22, 2012 23:16
everymodule#step method implementation
step: function (name) {
var steps = this._steps
, sequence = this._currSeq;
if (!sequence)
throw new Error("You can only declare a step after declaring a route alias via `get(...)` or `post(...)`.");
sequence.orderedStepNames.push(name);
this._currentStep =
@fruchtose
fruchtose / oauthAltCallbackSequence.js
Created November 22, 2012 23:21
Everyauth OAuth 1.0a alternate step sequence configuration
.get('callbackPath',
'the callback path that the 3rd party OAuth provider redirects to after an OAuth authorization result - e.g., "/auth/twitter/callback"')
.step('extractTokenAndVerifier', {
description: 'extracts the request token and verifier from the url query',
// ...
})
.step('getSession', {
// ...
})
// ...
@fruchtose
fruchtose / weibo.patch
Created November 24, 2012 02:37
Everyauth Weibo patch (with context)
var oauthModule = require('./oauth2')
, querystring= require('querystring')
, request = require('request');
var weibo = module.exports =
oauthModule.submodule('weibo')
.configurable({
scope: "There's no idea about weibo's scope"
})
@fruchtose
fruchtose / oauth2Sequences.js
Created November 24, 2012 02:49
Everyauth OAuth 2 submodule sequences
var weibo = module.exports =
oauthModule.submodule('weibo')
// ...
.get('entryPath',
'the link a user follows, whereupon you redirect them to the 3rd party OAuth provider dialog - e.g., "/auth/facebook"')
// ...
.get('callbackPath',
'the callback path that the 3rd party OAuth provider redirects to after an OAuth authorization result - e.g., "/auth/facebook/callback"')
// ...
.step('fetchOAuthUser')
@fruchtose
fruchtose / test_pg_array_literals.rb
Last active January 1, 2016 10:19
Test case for issue https://github.com/rails/rails/issues/13479,"array literals ignored in ActiveRecord#where" by BenLubar
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'pg'
GEMFILE
system 'bundle'
end