Module: HomeAway::API::Util::OAuth

Included in:
Client
Defined in:
lib/homeaway/api/util/oauth.rb

Instance Method Summary collapse

Instance Method Details

#auth_urlObject



29
30
31
# File 'lib/homeaway/api/util/oauth.rb', line 29

def auth_url
  oauth_client_strategy.authorize_url
end

#credentialsString

Returns the Base64 encoded credentials for the current client.

Returns:

  • (String)

    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

Parameters:

  • code (String)

    service ticket to authenticate

Returns:

  • (Boolean)

    true if the authentication succeeded, false otherwise



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