Parent

Net::Flickr::Auth

Implements the Flickr authentication API. Please see flickr.com/services/api/auth.spec.html for details on how to use this API in your application.

Don't instantiate this class yourself. Instead, create an instance of the Flickr class and then user Flickr.auth to access this class, like so:

require 'net/flickr'

flickr = Net::Flickr.new('524266cbd9d3c2xa2679fee8b337fip2',
    '835hae5d6j0sd47a')

puts flickr.auth.url_desktop

Attributes

frob[R]
perms[R]
token[R]
user_fullname[R]
user_id[R]
user_name[R]

Public Class Methods

new(flickr) click to toggle source
# File lib/net/flickr/auth.rb, line 54
def initialize(flickr)
  @flickr = flickr

  @frob          = nil
  @perms         = PERM_NONE
  @token         = nil
  @user_id       = nil
  @user_name     = nil
  @user_fullname = nil
end

Public Instance Methods

check_token(token = @token) click to toggle source

Updates this Auth object with the credentials attached to the specified authentication token. If the token is not valid, an APIError will be raised.

# File lib/net/flickr/auth.rb, line 72
def check_token(token = @token)
  update_auth(@flickr.request('flickr.auth.checkToken',
      'auth_token' => token))
  return true
end
full_token(mini_token) click to toggle source

Gets the full authentication token for the specified mini_token.

# File lib/net/flickr/auth.rb, line 79
def full_token(mini_token)
  update_auth(@flickr.request('flickr.auth.getFullToken',
      'mini_token' => mini_token))
  return @token
end
get_frob() click to toggle source

Gets a frob to be used during authentication.

# File lib/net/flickr/auth.rb, line 86
def get_frob
  response = @flickr.request('flickr.auth.getFrob').at('frob')
  return @frob = response.inner_text
end
get_token(frob = @frob) click to toggle source

Updates this Auth object with the credentials for the specified frob and returns an auth token. If the frob is not valid, an APIError will be raised.

# File lib/net/flickr/auth.rb, line 94
def get_token(frob = @frob)
  update_auth(@flickr.request('flickr.auth.getToken', 'frob' => frob))
  return @token
end
url_desktop(perms) click to toggle source

Gets a signed URL that can by used by a desktop application to show the user a Flickr authentication screen. Once the user has visited this URL and authorized your application, you can call get_token to authenticate.

# File lib/net/flickr/auth.rb, line 102
def url_desktop(perms)
  get_frob if @frob.nil?
  url = Flickr::AUTH_URL +
      "?api_key=#{@flickr.api_key}&perms=#{perms}&frob=#{@frob}"
  
  return @flickr.sign_url(url)
end
url_webapp(perms) click to toggle source

Gets a signed URL that can be used by a web application to show the user a Flickr authentication screen. Once the user has visited this URL and authorized your application, you can call get_token with the frob provided by Flickr to authenticate.

# File lib/net/flickr/auth.rb, line 114
def url_webapp(perms)
  return @flickr.sign_url(Flickr::AUTH_URL +
      "?api_key=#{@flickr.api_key}&perms=#{perms}")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.