Created
February 4, 2011 15:10
-
-
Save thurloat/811205 to your computer and use it in GitHub Desktop.
Is this un-readable?
This file contains 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
/** | |
* OAuth request message skeleton for every request. | |
* before the final url is generated, it must be run through | |
* the oauth Timestamp & Signature generators | |
* | |
* @constructor | |
*/ | |
sd.OAuth2.AuthMessage = function(code) { | |
if (code !== undefined) { | |
this.parameters = {}; | |
if(code == 'refresh_token'){ | |
this.parameters['refresh_token'] = sd.Prefs.get('refresh_token'); | |
this.parameters['grant_type'] = 'refresh_token'; | |
} else{ | |
this.parameters['code'] = code; | |
this.parameters['grant_type'] = 'authorization_code'; | |
} | |
this.parameters['client_id'] = sd.OAuth2.application_key; | |
this.parameters['client_secret'] = sd.OAuth2.application_key_secret; | |
this.parameters['redirect_uri'] = sd.OAuth2.close_url; | |
this.action = sd.OAuth2.token_url; | |
this.method = 'POST'; | |
} else { | |
this.parameters = { | |
response_type: 'code', | |
client_id: sd.OAuth2.application_key, | |
redirect_uri: sd.OAuth2.close_url}; | |
this.action = sd.OAuth2.authorize_url; | |
this.method = 'GET'; | |
} | |
}; |
This file contains 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
/** | |
* OAuth request message skeleton for every request. | |
* before the final url is generated, it must be run through | |
* the oauth Timestamp & Signature generators | |
* | |
* @constructor | |
*/ | |
sd.OAuth2.AuthMessage = function(code) { | |
var missing_code = (code === undefined); | |
this.parameters = missing_code | |
? { response_type: 'code', | |
client_id: sd.OAuth2.application_key, | |
redirect_uri: sd.OAuth2.close_url } | |
: (code == 'refresh_token') | |
? { refresh_token: sd.Prefs.get('refresh_token'), | |
grant_type: 'refresh_token', | |
client_id: sd.OAuth2.application_key, | |
client_secret: sd.OAuth2.application_key_secret, | |
redirect_uri: sd.OAuth2.close_url } | |
: { code: code, | |
grant_type: 'authorization_code', | |
client_id: sd.OAuth2.application_key, | |
client_secret: sd.OAuth2.application_key_secret, | |
redirect_uri: sd.OAuth2.close_url }; | |
this.action = missing_code ? sd.OAuth2.authorize_url : sd.OAuth2.token_url; | |
this.method = missing_code ? 'GET' : 'POST' | |
}; |
This file contains 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
/** | |
* OAuth request message skeleton for every request. | |
* before the final url is generated, it must be run through | |
* the oauth Timestamp & Signature generators | |
* | |
* @constructor | |
*/ | |
sd.OAuth2.AuthMessage = function(code) { | |
var missing_code = (code === undefined); | |
this.parameters = missing_code ? { response_type: 'code', client_id: sd.OAuth2.application_key, redirect_uri: sd.OAuth2.close_url } : (code == 'refresh_token') ? { refresh_token: sd.Prefs.get('refresh_token'), grant_type: 'refresh_token', client_id: sd.OAuth2.application_key, client_secret: sd.OAuth2.application_key_secret, redirect_uri: sd.OAuth2.close_url } : { code: code, grant_type: 'authorization_code', client_id: sd.OAuth2.application_key, client_secret: sd.OAuth2.application_key_secret, redirect_uri: sd.OAuth2.close_url }; | |
this.action = missing_code ? sd.OAuth2.authorize_url : sd.OAuth2.token_url; | |
this.method = missing_code ? 'GET' : 'POST' | |
}; |
I've updated the if statement to be more correct. Want to update your coffeescript?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CoffeeScript