Class: Patreon::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/patreon/oauth.rb

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret) ⇒ OAuth

Returns a new instance of OAuth.



3
4
5
6
# File 'lib/patreon/oauth.rb', line 3

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

Instance Method Details

#get_tokens(code, redirect_uri) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/patreon/oauth.rb', line 8

def get_tokens(code, redirect_uri)
  update_token({
      "grant_type" => "authorization_code",
      "code" => code,
      "client_id" => @client_id,
      "client_secret" => @client_secret,
      "redirect_uri" => redirect_uri
  })
end

#refresh_token(refresh_token, redirect_uri) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/patreon/oauth.rb', line 18

def refresh_token(refresh_token, redirect_uri)
  update_token({
      "grant_type" => "refresh_token",
      "refresh_token" => refresh_token,
      "client_id" => @client_id,
      "client_secret" => @client_secret
  })
end