Created
April 4, 2012 16:55
-
-
Save scan/2303817 to your computer and use it in GitHub Desktop.
Deviantart Strategy for Passport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
til = require('util') | |
OAuth2Strategy = require('passport-oauth').OAuth2Strategy | |
class Strategy extends OAuth2Strategy | |
constructor: (options = {}, verify) -> | |
options.authorizationURL or= 'https://www.deviantart.com/oauth2/draft15/authorize' | |
options.tokenURL or= 'https://www.deviantart.com/oauth2/draft15/token' | |
OAuth2Strategy.call this, options, verify | |
@name = 'deviantart' | |
userProfile: (accessToken, done) -> | |
@_oauth2.get 'https://www.deviantart.com/api/draft15/user/whoami', accessToken, (err, body, res) -> | |
if err then done err | |
else | |
try | |
json = JSON.parse body | |
profile = | |
provider: 'deviantart' | |
username: json.username | |
symbol: json.symbol | |
done null, profile | |
catch err | |
done err | |
# Inheriting done by CoffeeScript | |
# util.inherits DevartStrategy, OAuth2Strategy | |
module.exports.Strategy = Strategy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment