Sha256: da5a09545bb3af81dfdd4b309aa8da60f2f3cb4d62b0c18b4df56721c96eb3fd

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

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?
      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"
      params = access_token_params.merge(options)
      post("/oauth/access_token/", params.merge(:code => code), 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

1 entries across 1 versions & 1 rubygems

Version Path
instagram-0.11.0 lib/instagram/oauth.rb