class Redd::Clients::Installed
The client for installed apps that can't keep a secret. It might even work with Rubymotion (fingers crossed).
Attributes
client_id[R]
@!attribute [r] client_id
redirect_uri[R]
@!attribute [r] redirect_uri
Public Class Methods
new(client_id, redirect_uri, **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/installed.rb, line 18 def initialize(client_id, redirect_uri, **options) @client_id = client_id @redirect_uri = redirect_uri super(**options) end
Public Instance Methods
auth_url(state, scope = ['identity'], duration = :temporary)
click to toggle source
@param [String] state A random string to double-check later. @param [Array<String>] scope The scope to request access to. @param [:temporary, :permanent] duration @return [String] The url to redirect the user to. rubocop:disable Metrics/MethodLength
# File lib/redd/clients/installed.rb, line 29 def auth_url(state, scope = ['identity'], duration = :temporary) query = { response_type: 'token', client_id: @client_id, redirect_uri: @redirect_uri, state: state, scope: scope.join(','), duration: duration } url = URI.join(auth_endpoint, '/api/v1/authorize') url.query = URI.encode_www_form(query) url.to_s end