Sha256: 1616fdb56849def6c4fb88c59cf812e8b1a2a7b27ad9b89f31dc497a7b672845
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'uri' module Outreach class Authorization API_URL = 'https://api.outreach.io/oauth/token'.freeze attr_reader :token, :refresh_token, :expires_in def initialize(attrs) @token = attrs['access_token'] @refresh_token = attrs['refresh_token'] @expires_in = attrs['expires_in'] end 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 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
outreach-ruby-0.0.2 | lib/outreach-ruby/authorization.rb |