Sha256: 66c5cc4ea2b337839a5f6f9668520581fa73a161bf7dcd8072ec2bf8ecd4b741

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

module FlexmlsApi
  module Authentication
    # OAuth2 authentication flow to refresh an access token
    module OAuth2Impl
      class GrantTypeRefresh < GrantTypeBase
        attr_accessor :params
        def initialize(client, provider, session)
          super(client, provider, session)
          @params = {}
        end
        
        def authenticate
          new_session = nil
          unless @session.refresh_token.nil?
            FlexmlsApi.logger.debug("Refreshing authentication to #{provider.access_uri} using [#{session.refresh_token}]")
            new_session = create_session(token_params)
          end
          new_session 
        end
        
        private 
        def token_params
          @params.merge({
            "client_id" => @provider.client_id,
            "client_secret" => @provider.client_secret,
            "grant_type" => "refresh_token",
            "refresh_token"=> session.refresh_token,
          }).to_json 
        end
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flexmls_api-0.7.3 lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb
flexmls_api-0.7.0 lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb
flexmls_api-0.6.5 lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb
flexmls_api-0.6.4 lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb