Sha256: a8916570b55907f08969a3dd7393d9a793abe6ff5efbf1b95070fe051a701031

Contents?: true

Size: 1.02 KB

Versions: 14

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

14 entries across 14 versions & 1 rubygems

Version Path
spark_api-1.3.16 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.15 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.14 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.13 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.10 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.9 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.6 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.3 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.3.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.2.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.2.0 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.1.2 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb
spark_api-1.1.1 lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb