Class: FattureInCloud_Ruby_Sdk::OAuth2DeviceCodeManager
- Inherits:
-
OAuth2Manager
- Object
- OAuth2Manager
- FattureInCloud_Ruby_Sdk::OAuth2DeviceCodeManager
- Defined in:
- lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb
Overview
The OAuth2DeviceCodeManager class is used to manage the OAuth2 device code flow.
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
Instance Method Summary collapse
-
#fetch_token(code) ⇒ OAuth2TokenResponse
Get the access token.
-
#get_device_code(scopes) ⇒ OAuth2DeviceCodeResponse
Get the device code.
-
#initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') ⇒ OAuth2DeviceCodeManager
constructor
Initializes a new instance of the OAuth2DeviceCodeManager class.
-
#refresh_token(refresh_token) ⇒ OAuth2TokenResponse
Get the refresh token.
Methods inherited from OAuth2Manager
#execute_post, get_scope_string
Constructor Details
#initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') ⇒ OAuth2DeviceCodeManager
Initializes a new instance of the OAuth2DeviceCodeManager class.
124 125 126 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 124 def initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') super client_id, base_uri end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
119 120 121 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 119 def base_uri @base_uri end |
#client_id ⇒ Object
Returns the value of attribute client_id.
119 120 121 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 119 def client_id @client_id end |
Instance Method Details
#fetch_token(code) ⇒ OAuth2TokenResponse
Get the access token.
148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 148 def fetch_token(code) token_uri = "#{@base_uri}/oauth/token" data = { 'grant_type': 'urn:ietf:params:oauth:grant-type:device_code', 'client_id': @client_id, 'device_code': code, } json = execute_post(token_uri, data) OAuth2TokenResponse.new(json["token_type"], json['access_token'], json['refresh_token'], json['expires_in']) end |
#get_device_code(scopes) ⇒ OAuth2DeviceCodeResponse
Get the device code.
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 131 def get_device_code(scopes) device_uri = "#{@base_uri}/oauth/device" scope_string = OAuth2Manager.get_scope_string(scopes) data = { 'client_id': @client_id, 'scope': scope_string } json = execute_post(device_uri, data)["data"] OAuth2DeviceCodeResponse.new(json["device_code"], json['user_code'], json['scope'], json['verification_uri'], json['interval'], json['expires_in']) end |
#refresh_token(refresh_token) ⇒ OAuth2TokenResponse
Get the refresh token.
164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 164 def refresh_token(refresh_token) token_uri = "#{@base_uri}/oauth/token" data = { 'grant_type': 'refresh_token', 'client_id': @client_id, 'refresh_token': refresh_token, } json = execute_post(token_uri, data) OAuth2TokenResponse.new(json["token_type"], json['access_token'], json['refresh_token'], json['expires_in']) end |