Sha256: 29a787ab28b110ec64cb06b1d410415772e15e16e4b5b0484131410b7977108c

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module Instagram
  # Defines HTTP request methods
  module OAuth
    # Return URL for OAuth authorization
    def authorize_url(options = {})
      options[:response_type] ||= "code"
      options[:scope] ||= scope if !scope.nil? && !scope.empty?
      options[:redirect_uri] ||= redirect_uri
      params = authorization_params.merge(options)
      connection.build_url("/oauth/authorize/", params).to_s
    end

    # Return an access token from authorization
    def get_access_token(code, options = {})
      options[:grant_type] ||= "authorization_code"
      options[:redirect_uri] ||= redirect_uri
      params = access_token_params.merge(options)
      post("/oauth/access_token/", params.merge(code: code), signature = false, raw = false, unformatted = true, no_response_wrapper = true)
    end

    private

    def authorization_params
      {
        client_id: client_id,
      }
    end

    def access_token_params
      {
        client_id: client_id,
        client_secret: client_secret,
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
instagram-continued-continued-1.5.0 lib/instagram/oauth.rb
instagram-continued-1.4.0 lib/instagram/oauth.rb
instagram-continued-1.3.3 lib/instagram/oauth.rb
instagram-continued-1.3.2 lib/instagram/oauth.rb
instagram-continued-1.3.1 lib/instagram/oauth.rb