class NeonRAW::Clients::Script

The script app client.

Public Class Methods

new(username, password, client_id, secret, opts = {}) click to toggle source
# File lib/NeonRAW/clients/script.rb, line 7
def initialize(username, password, client_id, secret, opts = {})
  @username = username
  @password = password
  @client_id = client_id
  @secret = secret
  @redirect_uri = opts[:redirect_uri] || 'http://127.0.0.1:'
  @requests_remaining = 1
  @ratelimit_reset = 0
  @user_agent = opts[:user_agent] ||
                "Powered by NeonRAW v#{NeonRAW::VERSION}"
  authorize!
end

Public Instance Methods

authorize!() click to toggle source

Authorizes the client for oAuth2 requests. @!method authorize! @!method refresh_access!

# File lib/NeonRAW/clients/script.rb, line 23
def authorize!
  response = auth_connection(
    '/api/v1/access_token', :post,
    grant_type: 'password',
    username: @username,
    password: @password
  )
  data = JSON.parse(response.body, symbolize_names: true)
  @access = Objects::Access.new(data)
end
Also aliased as: refresh_access!
refresh_access!()
Alias for: authorize!