Module: Flickr::OAuth

Extended by:
OAuth
Included in:
OAuth
Defined in:
lib/flickr/oauth.rb

Overview

Interface for authenticating through OAuth.

Example:

request_token = Flickr::OAuth.get_request_token
request_token.authorize_url

# ... user visits the authorize URL, and gets the verifier ...

access_token = request_token.get_access_token(verifier)

access_token.key       # "..."
access_token.secret    # "..."
access_token. # {username: "...", nsid: "...", ...}

Defined Under Namespace

Classes: AccessToken, RequestToken, Token

Instance Method Summary collapse

Instance Method Details

#get_access_token(oauth_verifier, request_token) ⇒ Flickr::OAuth::AccessToken

Parameters:

  • oauth_verifier (String)

    The code provided by Flickr after visiting the authorize URL.

  • request_token (RequestToken, Array(String, String))

Returns:


46
47
48
49
50
51
# File 'lib/flickr/oauth.rb', line 46

def get_access_token(oauth_verifier, request_token)
  params = {oauth_verifier: oauth_verifier}
  response = client(request_token.to_a).get_access_token(params)
  AccessToken.new(response[:oauth_token], response[:oauth_token_secret],
    response.reject { |key, value| [:oauth_token, :oauth_token_secret].include?(key) })
end

#get_request_token(params = {}) ⇒ Flickr::OAuth::RequestToken

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :callback_url (String)

    If the user is being authorized through another web application, this parameter can be used to redirect the user back to that application.

Returns:


33
34
35
36
37
# File 'lib/flickr/oauth.rb', line 33

def get_request_token(params = {})
  params[:oauth_callback] = params.delete(:callback_url)
  response = client.get_request_token(params)
  RequestToken.new(response[:oauth_token], response[:oauth_token_secret])
end