Sha256: e472be84bd00208846162076c31a5d2205da69730b16aed1a210faa0ce4e994c

Contents?: true

Size: 986 Bytes

Versions: 70

Compression:

Stored size: 986 Bytes

Contents

module SparkApi
  module Configuration
    module OAuth2Configurable
      def convert_to_oauth2?
        (self.authentication_mode == SparkApi::Authentication::OAuth2 ||
         self.authentication_mode == SparkApi::Authentication::OpenId ||
         self.authentication_mode == SparkApi::Authentication::OpenIdOAuth2Hybrid) &&
          self.oauth2_provider.nil? 
      end

      def oauth2_enabled?
        self.authentication_mode == SparkApi::Authentication::OAuth2
      end

      def oauthify!
        self.oauth2_provider = SparkApi::Authentication::SimpleProvider.new(
          :access_uri    => grant_uri,
          :client_id     => self.api_key,
          :client_secret => self.api_secret,
          :authorization_uri => self.auth_endpoint,
          :redirect_uri  => self.callback
        )
      end

      def grant_uri
        e = self.endpoint.gsub(/\/+$/,"")
        v = self.version.gsub(/\/+/,"/")
        "#{e}/#{v}/oauth2/grant"
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
spark_api-1.6.3 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.6.2 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.6.1 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.7 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.6.0 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.6 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.5 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.4 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.3 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.2 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.1 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.5.0 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.34 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.32 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.31 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.29 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.28 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.27 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.26 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.25 lib/spark_api/configuration/oauth2_configurable.rb