Skip to content

Instantly share code, notes, and snippets.

@scan
Created April 4, 2012 16:55
Show Gist options
  • Save scan/2303817 to your computer and use it in GitHub Desktop.
Save scan/2303817 to your computer and use it in GitHub Desktop.
Deviantart Strategy for Passport
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