Module: RubyInstagram::OAuth

Included in:
API
Defined in:
lib/ruby_instagram/oauth.rb

Constant Summary collapse

OAUTH_ENDPOINT =
'https://api.instagram.com/'

Instance Method Summary collapse

Instance Method Details

#authorize_url(options = {}) ⇒ Object

Return URL for OAuth authorization



7
8
9
10
11
12
13
14
# File 'lib/ruby_instagram/oauth.rb', line 7

def authorize_url(options = {})
  send('endpoint=', OAUTH_ENDPOINT)
  options[:response_type] ||= 'code'
  options[:redirect_uri] ||= options[:redirect_uri]
  options[:scope] ||= scope
  params = authorization_params.merge(options)
  connection.build_url('/oauth/authorize/', params).to_s
end

#get_access_token(code, options = {}) ⇒ Object

Return an access token from authorization



17
18
19
20
21
22
23
# File 'lib/ruby_instagram/oauth.rb', line 17

def get_access_token(code, options = {})
  send('endpoint=', OAUTH_ENDPOINT)
  options[:grant_type] ||= 'authorization_code'
  options[:redirect_uri] ||= redirect_uri
  params = access_token_params.merge(options)
  post('/oauth/access_token/', params.merge(code: code))
end