Sha256: c4a99a4da2f0987c113349b89d589cdc74f68ddbc4cd44262d7cd54aa15475ef

Contents?: true

Size: 1.02 KB

Versions: 55

Compression:

Stored size: 1.02 KB

Contents

module SparkApi
  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?
            SparkApi.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
          hash = @params.merge({
            "client_id" => @provider.client_id,
            "client_secret" => @provider.client_secret,
            "grant_type" => "refresh_token",
            "refresh_token"=> session.refresh_token,
          }) 
          MultiJson.dump(hash)
        end
      end
      
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
spark_api-2.0.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.6.3 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.6.2 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.6.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.7 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.6.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.6 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.5 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.4 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.3 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.2 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.5.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.34 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.32 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.31 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.29 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.28 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.27 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.4.26 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb