Class: Trello::Authorization::OAuthPolicy
- Inherits:
-
Object
- Object
- Trello::Authorization::OAuthPolicy
- Defined in:
- lib/trello/authorization.rb
Overview
Handles the OAuth connectivity to Trello.
For 2-legged OAuth, do the following:
OAuthPolicy.consumer_credential = OAuthCredential.new "public_key", "secret"
OAuthPolicy.token = OAuthCredential.new "token_key", nil
For 3-legged OAuth, do the following:
OAuthPolicy.consumer_credential = OAuthCredential.new "public_key", "secret"
OAuthPolicy.return_url = "http://your.site.com/path/to/receive/post"
OAuthPolicy.callback = Proc.new do |request_token|
DB.save(request_token.key, request_token.secret)
redirect_to request_token.
end
Then, recreate the request token given the request token key and secret you saved earlier, and the consumer, and pass that RequestToken instance the #get_access_token method, and store that in OAuthPolicy.token as a OAuthCredential.
Class Attribute Summary collapse
-
.callback ⇒ Object
Returns the value of attribute callback.
-
.consumer_credential ⇒ Object
Returns the value of attribute consumer_credential.
-
.return_url ⇒ Object
Returns the value of attribute return_url.
-
.token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Class Attribute Details
.callback ⇒ Object
Returns the value of attribute callback.
57 58 59 |
# File 'lib/trello/authorization.rb', line 57 def callback @callback end |
.consumer_credential ⇒ Object
Returns the value of attribute consumer_credential.
57 58 59 |
# File 'lib/trello/authorization.rb', line 57 def consumer_credential @consumer_credential end |
.return_url ⇒ Object
Returns the value of attribute return_url.
57 58 59 |
# File 'lib/trello/authorization.rb', line 57 def return_url @return_url end |
.token ⇒ Object
Returns the value of attribute token.
57 58 59 |
# File 'lib/trello/authorization.rb', line 57 def token @token end |
Class Method Details
.authorize(request) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/trello/authorization.rb', line 59 def (request) unless consumer_credential Trello.logger.error "The consumer_credential has not been supplied." fail "The consumer_credential has not been supplied." end if token request.headers = {"Authorization" => get_auth_header(request.uri, :get)} request else consumer(:return_url => return_url, :callback_method => :postMessage) request_token = consumer.get_request_token callback.call request_token return nil end end |