Class: Redd::AuthStrategies::Script

Inherits:
AuthStrategy show all
Defined in:
lib/redd/auth_strategies/script.rb

Overview

A password-based authentication scheme. Requests all scopes.

Constant Summary

Constants inherited from AuthStrategy

AuthStrategy::AUTH_ENDPOINT

Constants inherited from Client

Client::USER_AGENT

Instance Method Summary collapse

Methods inherited from AuthStrategy

#revoke

Methods inherited from Client

#delete, #get, #patch, #post, #put, #request

Constructor Details

#initialize(client_id:, secret:, username:, password:, **kwargs) ⇒ Script

Returns a new instance of Script.


9
10
11
12
13
# File 'lib/redd/auth_strategies/script.rb', line 9

def initialize(client_id:, secret:, username:, password:, **kwargs)
  super(client_id: client_id, secret: secret, **kwargs)
  @username = username
  @password = password
end

Instance Method Details

#authenticateAccess

Perform authentication and return the resulting access object

Returns:

  • (Access)

    the access token object


17
18
19
# File 'lib/redd/auth_strategies/script.rb', line 17

def authenticate
  request_access('password', username: @username, password: @password)
end

#refresh(_) ⇒ Access

Refresh the authentication and return the refreshed access

Returns:

  • (Access)

    the new access


23
24
25
# File 'lib/redd/auth_strategies/script.rb', line 23

def refresh(_)
  authenticate
end