Module: FidorApi::Auth

Extended by:
Auth
Included in:
Auth
Defined in:
lib/fidor_api/auth.rb

Instance Method Summary collapse

Instance Method Details

#authorize_url(callback_url: nil) ⇒ Object



6
7
8
# File 'lib/fidor_api/auth.rb', line 6

def authorize_url(callback_url: nil)
  fidor_authorize_url(callback_url: callback_url)
end

#fetch_token(code, callback_url: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/fidor_api/auth.rb', line 10

def fetch_token(code, callback_url: nil)
  response = connection.post "/oauth/token", {
    client_id:    FidorApi.configuration.client_id,
    redirect_uri: callback_url || FidorApi.configuration.callback_url,
    code:         code,
    grant_type:   "authorization_code"
  }
  Token.new JSON.parse(response.body)
end

#refresh_token(token) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/fidor_api/auth.rb', line 20

def refresh_token(token)
  response = connection.post "/oauth/token", {
    grant_type:    "refresh_token",
    refresh_token: token.refresh_token
  }
  Token.new JSON.parse(response.body)
end