Module: Fog::Brightbox::OAuth2
- Included in:
- Compute::Shared
- Defined in:
- lib/fog/brightbox/oauth2.rb
Overview
This module covers Brightbox’s partial implementation of OAuth 2.0 and enables fog clients to implement several authentictication strategies
Defined Under Namespace
Classes: ClientCredentialsStrategy, CredentialSet, GrantTypeStrategy, RefreshTokenStrategy, UserCredentialsStrategy
Instance Method Summary collapse
-
#request_access_token(connection, credentials) ⇒ Excon::Response
This builds the simplest form of requesting an access token based on the arguments passed in.
Instance Method Details
#request_access_token(connection, credentials) ⇒ Excon::Response
This builds the simplest form of requesting an access token based on the arguments passed in
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/brightbox/oauth2.rb', line 15 def request_access_token(connection, credentials) token_strategy = credentials.best_grant_strategy header_content = "#{credentials.client_id}:#{credentials.client_secret}" encoded_credentials = Base64.encode64(header_content).chomp connection.request({ :path => "/token", :expects => 200, :headers => { 'Authorization' => "Basic #{encoded_credentials}", 'Content-Type' => 'application/json' }, :method => 'POST', :body => Fog::JSON.encode(token_strategy.) }) end |