Class: RDStation::Authentication

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rdstation/authentication.rb

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret) ⇒ Authentication

Returns a new instance of Authentication.



6
7
8
9
# File 'lib/rdstation/authentication.rb', line 6

def initialize(client_id, client_secret)
  @client_id = client_id
  @client_secret = client_secret
end

Instance Method Details

#auth_url(redirect_url) ⇒ Object

param redirect_url

URL that the user will be redirected
after confirming application authorization


16
17
18
# File 'lib/rdstation/authentication.rb', line 16

def auth_url(redirect_url)
  "https://api.rd.services/auth/dialog?client_id=#{@client_id}&redirect_url=#{redirect_url}"
end

#authenticate(code) ⇒ Object

param code

parameter sent by RDStation after user confirms authorization


24
25
26
# File 'lib/rdstation/authentication.rb', line 24

def authenticate(code)
  post_to_auth_endpoint({ :code => code })
end

#update_access_token(refresh_token) ⇒ Object

param refresh_token

parameter sent by RDStation after authenticate


32
33
34
# File 'lib/rdstation/authentication.rb', line 32

def update_access_token(refresh_token)
  post_to_auth_endpoint({ :refresh_token => refresh_token })
end