Sha256: 13886a9eb55c0f58939bf930200aaa6b73769bb2d50127893a2774abb839c952
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'signet/oauth_2/client' require 'active_support/core_ext/hash/indifferent_access' module Spearly module Auth class Authorizer def initialize(params) @params = params.deep_symbolize_keys @client = initialize_client end def method_missing(name, *args) @client.send(name, *args) rescue Signet::AuthorizationError raise Spearly::Auth::AuthorizationError end def respond_to_missing?(_name, *_args) true end private def initialize_client Faraday.default_connection_options = { headers: { 'Accept' => 'application/vnd.spearly.v2+json' } } ::Signet::OAuth2::Client.new( client_id: @params[:client_id], client_secret: @params[:client_secret], code: @params[:code], grant_type: @params[:grant_type], authorization_uri: "#{ENV.fetch('SPEARLY_API_URL', nil)}/oauth/authorize", token_credential_uri: "#{ENV.fetch('SPEARLY_API_URL', nil)}/oauth/token", redirect_uri: @params[:redirect_uri], access_token: @params[:access_token], refresh_token: @params[:refresh_token], id_token: @params[:id_token], expires_in: @params[:expires_in], issued_at: @params[:issued_at], expires_at: @params[:expires_at] ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spearly-sdk-ruby-0.10.0 | lib/spearly/auth/authorizer.rb |
spearly-sdk-ruby-0.9.0 | lib/spearly/auth/authorizer.rb |