Skip to content

Instantly share code, notes, and snippets.

@brett-shwom
Created March 7, 2014 21:14
Show Gist options
  • Save brett-shwom/9420245 to your computer and use it in GitHub Desktop.
Save brett-shwom/9420245 to your computer and use it in GitHub Desktop.
OAuth.initialize(config.oauthio.publicKey)
var oauthioResult
, twitterUser
, twitterUserProfile
OAuth
.callback('twitter', function(err, _oauthioResult) { //callback happens after the redirect
var promise = new Promise
if (err) {
console.warn('error with twitter auth', err)
promise.reject(err)
}
else {
promise.fulfill(_oauthioResult)
oauthioResult = _oauthioResult
}
console.log('logged into twitter')
return promise
.then(function() {
console.log('getting user credentials')
return oauthioResult.get('/1.1/account/verify_credentials.json')
})
.then(function (_twitterUser) {
twitterUser = _twitterUser
//console.log('got profile for', twitterUser.screen_name)
//twitterUserProfile = _twitterUserProfile
var auth = new FirebaseSimpleLogin(firebase, function(error, firebaseUser) {
//is something supposed to go in here?
})
auth.login('twitter', {
oauth_token: oauthioResult.oauth_token,
oauth_token_secret : oauthioResult.oauth_token_secret,
user_id : twitterUser.screen_name //this should probably be a uniqueId
})
},
//onerror
function () {console.log('error getting profile')}
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment