Class: Fog::Brightbox::OAuth2::GrantTypeStrategy Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/brightbox/oauth2.rb

Overview

This class is abstract.

Need to implement #authorization_body_data to return a Hash matching the expected parameter form for the OAuth request

TODO:

Strategies should be able to validate if credentials are suitable so just client credentials cannot be used with user strategies

This strategy class is the basis for OAuth2 grant types

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ GrantTypeStrategy

Returns a new instance of GrantTypeStrategy.



129
130
131
# File 'lib/fog/brightbox/oauth2.rb', line 129

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#authorization_body_dataObject



133
134
135
# File 'lib/fog/brightbox/oauth2.rb', line 133

def authorization_body_data
  raise "Not implemented"
end

#authorization_headerObject



137
138
139
140
# File 'lib/fog/brightbox/oauth2.rb', line 137

def authorization_header
  header_content = "#{@credentials.client_id}:#{@credentials.client_secret}"
  "Basic #{Base64.encode64(header_content).chomp}"
end

#headersObject



142
143
144
145
146
147
# File 'lib/fog/brightbox/oauth2.rb', line 142

def headers
  {
    "Authorization" => authorization_header,
    "Content-Type" => "application/json"
  }
end