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.4.24 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.23 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.22 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.21 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.20 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.19 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.18 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.17 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.16 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.15 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.14 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.13 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.12 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.11 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.10 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.9 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.8 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.6 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.5 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.4 lib/spark_api/configuration/oauth2_configurable.rb