class Outreach::Authorization

Constants

API_URL

Attributes

expires_in[R]
refresh_token[R]
token[R]

Public Class Methods

authorization_url() click to toggle source
# File lib/outreach/authorization.rb, line 15
def self.authorization_url
  url = "https://api.outreach.io/oauth/authorize"
  params = {
    client_id:     Outreach.application_identifier,
    redirect_uri:  Outreach.redirect_uri,
    response_type: 'code',
    scope:         Outreach.scopes
  }
  url + "?" + URI.encode_www_form(params)
end
create(authorization_code) click to toggle source
# File lib/outreach/authorization.rb, line 26
def self.create(authorization_code)
  params = {
    client_id:     Outreach.application_identifier,
    client_secret: Outreach.application_secret,
    redirect_uri:  Outreach.redirect_uri,
    grant_type:    'authorization_code',
    code:          authorization_code
  }
  response = Outreach::Request.new.post(API_URL, params)
  new(response)
end
new(attrs) click to toggle source
# File lib/outreach/authorization.rb, line 9
def initialize(attrs)
  @token = attrs['access_token']
  @refresh_token = attrs['refresh_token']
  @expires_in = attrs['expires_in']
end
refresh(refresh_token) click to toggle source
# File lib/outreach/authorization.rb, line 38
def self.refresh(refresh_token)
  params = {
    client_id:     Outreach.application_identifier,
    client_secret: Outreach.application_secret,
    redirect_uri:  Outreach.redirect_uri,
    grant_type:    'refresh_token',
    refresh_token: refresh_token
  }
  response = Request.new.post(API_URL, params)
  new(response)
end