Parent

Class/Module Index [+]

Quicksearch

Fog::Brightbox::OAuth2::CredentialSet

Encapsulates credentials required to request access tokens from the Brightbox authorisation servers

@todo Interface to update certain credentials (after password change)

Attributes

access_token[R]
client_id[R]
client_secret[R]
password[R]
refresh_token[R]
username[R]

Public Class Methods

new(client_id, client_secret, options = {}) click to toggle source

@param [String] client_id @param [String] client_secret @param [Hash] options @option options [String] :username @option options [String] :password

# File lib/fog/brightbox/oauth2.rb, line 48
def initialize(client_id, client_secret, options = {})
  @client_id     = client_id
  @client_secret = client_secret
  @username      = options[:username]
  @password      = options[:password]
  @access_token  = options[:access_token]
  @refresh_token = options[:refresh_token]
end

Public Instance Methods

access_token?() click to toggle source

Is an access token available for these credentials?

# File lib/fog/brightbox/oauth2.rb, line 64
def access_token?
  !!@access_token
end
best_grant_strategy() click to toggle source

Based on available credentials returns the best strategy

@todo Add a means to dictate which should or shouldn't be used

# File lib/fog/brightbox/oauth2.rb, line 83
def best_grant_strategy
  if refresh_token?
    RefreshTokenStrategy.new(self)
  elsif user_details?
    UserCredentialsStrategy.new(self)
  else
    ClientCredentialsStrategy.new(self)
  end
end
refresh_token?() click to toggle source

Is a refresh token available for these credentials?

# File lib/fog/brightbox/oauth2.rb, line 69
def refresh_token?
  !!@refresh_token
end
update_tokens(access_token, refresh_token = nil) click to toggle source

Updates the credentials with newer tokens

# File lib/fog/brightbox/oauth2.rb, line 74
def update_tokens(access_token, refresh_token = nil)
  @access_token  = access_token
  @refresh_token = refresh_token
end
user_details?() click to toggle source

Returns true if user details are available @return [Boolean]

# File lib/fog/brightbox/oauth2.rb, line 59
def user_details?
  !!(@username && @password)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.