Module: OpenAuth2::Connection

Defined in:
lib/open_auth2/connection.rb

Overview

Client/Token use this to make the actual requests to OAuth server. Since some OAuth servers have seperate endpoints for authorization & api requests, we use @faraday_url to store that info.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
# File 'lib/open_auth2/connection.rb', line 8

def self.included(base)
  base.class_eval do
    attr_accessor :faraday_url
  end
end

Instance Method Details

#connection(&blk) ⇒ Object

Yields: Faraday object, so user can choose choose their own middleware.

Examples:

config = OpenAuth2::Config.new
client = OpenAuth2::Client.new(config)

client.connection do
  response :logger
end

Returns: Faraday object.



27
28
29
30
31
32
33
34
35
# File 'lib/open_auth2/connection.rb', line 27

def connection(&blk)
  @connection ||= Faraday.new(:url => @faraday_url) do |builder|
    builder.request :url_encoded
    builder.adapter :net_http
    builder.instance_eval(&blk) if block_given?
  end

  @connection
end