Sha256: 095c8721092ecde33119b0b1e81af0fbd6986432b7c806f29cecc6d52c4b8499

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true
module BitBucket
  module Authorization
    # Check whether authentication credentials are present
    def authenticated?
      basic_authed? || oauth_token?
    end

    # Check whether basic authentication credentials are present
    def basic_authed?
      basic_auth? || (login? && password?)
    end

    # Select authentication parameters
    def authentication
      if basic_auth?
        { basic_auth: basic_auth }
      elsif login? && password?
        { login: login, password: password }
      else
        {}
      end
    end

    private

    def _verify_client # :nodoc:
      raise ArgumentError, 'Need to provide client_id and client_secret' unless client_id? && client_secret?
    end
  end # Authorization
end # BitBucket

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 lib/bitbucket_rest_api/authorization.rb