class NeonRAW::Clients::Web
The Web
app client.
Public Class Methods
new(client_id, secret, redirect_uri, opts = {})
click to toggle source
# File lib/NeonRAW/clients/web.rb, line 8 def initialize(client_id, secret, redirect_uri, opts = {}) @client_id = client_id @secret = secret @redirect_uri = redirect_uri @requests_remaining = 1 @ratelimit_reset = 0 @user_agent = opts[:user_agent] || "Powered by NeonRAW v#{NeonRAW::VERSION}" end
Public Instance Methods
auth_url(state, scope = ['identity'], duration = 'temporary')
click to toggle source
Generates the authorization URL. @!method auth_url
(state, scope = ['identity'], duration = 'temporary') @param state [String] A random string to check later. @param scope [Array<String>] The scopes your app uses. @param duration [String] The duration of the access token [temporary,
permanent].
@return [String] Returns the URL.
# File lib/NeonRAW/clients/web.rb, line 25 def auth_url(state, scope = ['identity'], duration = 'temporary') query = { response_type: 'code', client_id: @client_id, redirect_uri: @redirect_uri, state: state, scope: scope.join(','), duration: duration } url = URI.join('https://www.reddit.com', '/api/v1/authorize') url.query = URI.encode_www_form(query) url.to_s end