class Redd::Clients::Script

The client for an account you own (e.g. bots).

Attributes

client_id[R]

@!attribute [r] client_id

username[R]

@!attribute [r] username

Public Class Methods

new(client_id, secret, username, password, **options) click to toggle source

@param [Hash] options The options to create the client with. @see Base#initialize @see Redd.it

Calls superclass method Redd::Clients::Base::new
# File lib/redd/clients/script.rb, line 16
def initialize(client_id, secret, username, password, **options)
  @client_id = client_id
  @secret = secret
  @username = username
  @password = password
  super(**options)
end

Public Instance Methods

authorize!() click to toggle source

Authorize using the given data. @return [Access] The access given by reddit.

# File lib/redd/clients/script.rb, line 26
def authorize!
  # reset the connection for when the access token is refreshed
  @connection = nil
  response = auth_connection.post(
    '/api/v1/access_token',
    grant_type: 'password',
    username: @username,
    password: @password
  )

  @access = Access.new(response.body)
end
Also aliased as: refresh_access!
refresh_access!()
Alias for: authorize!