Sha256: 4a6ae90608b863956a48befc1e73e6d506eadd1fcdf449c59168f4ab1db8779e
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'uri' module Outreach class Authorization API_URL = "https://api.outreach.io/oauth/token" 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 = 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-0.0.1 | lib/outreach/authorization.rb |