Sha256: 4ea939f8ed9f029604a314e0ea020f49173c576250bf4d86b7e20c3e215d436c

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 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("[oauth2] 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 & 2 rubygems

Version Path
spark_api-1.0.2 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb~
spark_api-1.0.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb~
spark_api-1.0.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb~
flexmls_api-0.7.5 lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb