Sha256: 78df6ef22590925c57632cedc96142981626d2f8cfe73a1336db10a4baa33be8

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 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] ||= self.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] ||= self.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

18 entries across 18 versions & 4 rubygems

Version Path
extendi-instagram-2.0.6 lib/instagram/oauth.rb
extendi-instagram-2.0.5 lib/instagram/oauth.rb
extendi-instagram-2.0.4 lib/instagram/oauth.rb
extendi-instagram-2.0.3 lib/instagram/oauth.rb
extendi-instagram-2.0.2 lib/instagram/oauth.rb
extendi-instagram-2.0.1 lib/instagram/oauth.rb
extendi-instagram-2.0.0 lib/instagram/oauth.rb
instagram-continued-1.3.0 lib/instagram/oauth.rb
instagram-community-maintained-1.1.6 lib/instagram/oauth.rb
instagram-continued-1.2.1 lib/instagram/oauth.rb
instagram-continued-1.2.0 lib/instagram/oauth.rb
instagram-1.1.6 lib/instagram/oauth.rb
instagram-1.1.5 lib/instagram/oauth.rb
instagram-1.1.4 lib/instagram/oauth.rb
instagram-1.1.3 lib/instagram/oauth.rb
instagram-1.1.2 lib/instagram/oauth.rb
instagram-1.1.1 lib/instagram/oauth.rb
instagram-1.1.0 lib/instagram/oauth.rb