Module: HomeAway::API::Util::OAuth
- Included in:
- Client
- Defined in:
- lib/homeaway/api/util/oauth.rb
Instance Method Summary collapse
- #auth_url ⇒ Object
-
#credentials ⇒ String
The Base64 encoded credentials for the current client.
-
#oauth_code=(code) ⇒ Boolean
completes the oauth flow.
Instance Method Details
#auth_url ⇒ Object
29 30 31 |
# File 'lib/homeaway/api/util/oauth.rb', line 29 def auth_url oauth_client_strategy. end |
#credentials ⇒ String
Returns the Base64 encoded credentials for the current client.
24 25 26 |
# File 'lib/homeaway/api/util/oauth.rb', line 24 def credentials Base64.strict_encode64 "#{@configuration.client_id}:#{@configuration.client_secret}" end |
#oauth_code=(code) ⇒ Boolean
completes the oauth flow
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/homeaway/api/util/oauth.rb', line 36 def oauth_code=(code) begin auth_code_strategy = oauth_client_strategy token = auth_code_strategy.get_token(code, :headers => {'Authorization' => "Basic #{credentials}"}) @token = token.token @token_expires = Time.at token.expires_at @refresh_token = token.refresh_token @mode = :three_legged return true rescue => _ raise HomeAway::API::Errors::UnauthorizedError.new end end |