Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/freeagent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,21 @@ def access_details(client_id, client_secret, access_token=nil)
@client = Client.new(client_id, client_secret)
@client.access_token = access_token if access_token
end

def authorize(options)
@client.authorize(options)
end

def fetch_access_token(auth_token, options)
@client.fetch_access_token(auth_token, options)
end

def access_token=(access_token)
@client.access_token = access_token
end

def access_token
@client.access_token.token
end
end
end
8 changes: 8 additions & 0 deletions lib/freeagent/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def self.token_url
def self.connection_opts
{ :headers => { :user_agent => "freeagent-api-rb", :accept => "application/json", :content_type => "application/json" } }
end

def authorize(options)
if options[:redirect_uri]
@client.auth_code.authorize_url(options)
else
raise FreeAgent::ClientError.new('Redirect uri not specified')
end
end

def fetch_access_token(auth_code, options)
if options[:redirect_uri]
Expand Down