Class: Fakturoid::Oauth::Flow::AuthorizationCode
- Inherits:
-
Object
- Object
- Fakturoid::Oauth::Flow::AuthorizationCode
- Includes:
- Base
- Defined in:
- lib/fakturoid/oauth/flow/authorization_code.rb
Constant Summary collapse
- GRANT_TYPE =
"authorization_code"
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #authorization_uri(state: nil) ⇒ Object
- #authorize(code:) ⇒ Object
- #authorized? ⇒ Boolean
- #fetch_access_token ⇒ Object
- #revoke_access ⇒ Object
Methods included from Base
Instance Method Details
#authorization_uri(state: nil) ⇒ Object
11 12 13 |
# File 'lib/fakturoid/oauth/flow/authorization_code.rb', line 11 def (state: nil) client.config.(state: state) end |
#authorize(code:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fakturoid/oauth/flow/authorization_code.rb', line 15 def (code:) payload = { grant_type: GRANT_TYPE, redirect_uri: client.config.redirect_uri, code: code } response = perform_request(HTTP_POST, "token.json", payload: payload) client.config.credentials.update(response.body) client.call_credentials_updated_callback response end |
#authorized? ⇒ Boolean
47 48 49 |
# File 'lib/fakturoid/oauth/flow/authorization_code.rb', line 47 def !Utils.empty?(client.config.credentials.refresh_token) end |
#fetch_access_token ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fakturoid/oauth/flow/authorization_code.rb', line 28 def fetch_access_token payload = { grant_type: "refresh_token", refresh_token: client.config.credentials.refresh_token } response = perform_request(HTTP_POST, "token.json", payload: payload) client.config.credentials.update(response.body) response end |
#revoke_access ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fakturoid/oauth/flow/authorization_code.rb', line 39 def revoke_access payload = { token: client.config.credentials.refresh_token } perform_request(HTTP_POST, "revoke.json", payload: payload) end |