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.2 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.1 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.4.0 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.28 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.27 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.26 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.25 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.24 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.23 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.21 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.20 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.19 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.18 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.17 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.16 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.15 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.14 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.13 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.10 lib/spark_api/configuration/oauth2_configurable.rb
spark_api-1.3.9 lib/spark_api/configuration/oauth2_configurable.rb