Class: Tmdby::Authentication

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/tmdby/helpers/authentication.rb,
lib/tmdby/wrappers/authentication.rb

Class Method Summary collapse

Methods inherited from Wrapper

add_default_language, fetch, handle_post_params, route, verify_params

Class Method Details

.get_session_id(username, password) ⇒ Object

Generate a session id using TMDB credentials



5
6
7
8
9
10
11
12
13
14
# File 'lib/tmdby/helpers/authentication.rb', line 5

def self.get_session_id(username, password)
  begin
    token = self.token_new.body["request_token"]
    self. token, username, password

    return (self.session_new token).body["session_id"]
  rescue
    return false
  end
end

.guest_session_newObject

This method is used to generate a guest session id.



28
29
30
# File 'lib/tmdby/wrappers/authentication.rb', line 28

def self.guest_session_new
  self.fetch "guest_session/new"
end

.session_new(request_token) ⇒ Object

This method is used to generate a session id for user based authentication.



21
22
23
24
25
# File 'lib/tmdby/wrappers/authentication.rb', line 21

def self.session_new(request_token)
  self.fetch "session/new",
              request_token: request_token,
              authorized_params: ["request_token"]
end

.token_newObject

This method is used to generate a valid request token for user based authentication.



7
8
9
# File 'lib/tmdby/wrappers/authentication.rb', line 7

def self.token_new
  self.fetch "token/new"
end

.token_validate_with_login(request_token, username, password) ⇒ Object

Once you have a valid request token you can use this method to authenticate a user with a TMDb username and password.



12
13
14
15
16
17
18
# File 'lib/tmdby/wrappers/authentication.rb', line 12

def self.(request_token, username, password)
  self.fetch "token/validate_with_login",
              request_token: request_token,
              username: username,
              password: password,
              authorized_params: ["request_token", "username", "password"]
end