class OAuth2::Strategy::ClientCredentials

The Client Credentials Strategy

@see tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.4

Public Instance Methods

authorize_url() click to toggle source

Not used for this strategy

@raise [NotImplementedError]

# File lib/oauth2/strategy/client_credentials.rb, line 12
def authorize_url
  raise NotImplementedError, "The authorization endpoint is not used in this strategy"
end
get_token(params={}, opts={}) click to toggle source

Retrieve an access token given the specified client.

@param [Hash] params additional params @param [Hash] opts options

# File lib/oauth2/strategy/client_credentials.rb, line 20
def get_token(params={}, opts={})
  request_body = opts.delete('auth_scheme') == 'request_body'
  params.merge!('grant_type' => 'client_credentials')
  params.merge!(request_body ? client_params : {:headers => {'Authorization' => HTTPAuth::Basic.pack_authorization(client_params['client_id'], client_params['client_secret'])}})
  @client.get_token(params, opts.merge('refresh_token' => nil))
end