Class: GSheets::Oauth::Offline
- Inherits:
-
Object
- Object
- GSheets::Oauth::Offline
- Defined in:
- lib/g_sheets/oauth/offline.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#signet_client ⇒ Object
readonly
Returns the value of attribute signet_client.
Instance Method Summary collapse
- #get_access_token(authentication_code: nil, refresh_token: nil) ⇒ Object
- #get_authentication_uri ⇒ Object
- #get_refresh_token(authentication_code:) ⇒ Object
-
#initialize(client_id, client_secret, scope: default_scopes, signet_client: nil) ⇒ Offline
constructor
A new instance of Offline.
Constructor Details
#initialize(client_id, client_secret, scope: default_scopes, signet_client: nil) ⇒ Offline
Returns a new instance of Offline.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/g_sheets/oauth/offline.rb', line 8 def initialize( client_id, client_secret, scope: default_scopes, signet_client: nil ) @client_id = client_id @client_secret = client_secret @scope = scope @signet_client = signet_client || get_signet_client end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/g_sheets/oauth/offline.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/g_sheets/oauth/offline.rb', line 6 def client_secret @client_secret end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/g_sheets/oauth/offline.rb', line 6 def scope @scope end |
#signet_client ⇒ Object (readonly)
Returns the value of attribute signet_client.
6 7 8 |
# File 'lib/g_sheets/oauth/offline.rb', line 6 def signet_client @signet_client end |
Instance Method Details
#get_access_token(authentication_code: nil, refresh_token: nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/g_sheets/oauth/offline.rb', line 24 def get_access_token(authentication_code: nil, refresh_token: nil) = "you must provide either an authentication_code or refresh_token".freeze raise ArgumentError, if authentication_code.nil? && refresh_token.nil? @signet_client.code = authentication_code if authentication_code @signet_client.refresh_token = refresh_token if refresh_token @signet_client.fetch_access_token! @signet_client.access_token end |
#get_authentication_uri ⇒ Object
20 21 22 |
# File 'lib/g_sheets/oauth/offline.rb', line 20 def get_authentication_uri @signet_client. end |
#get_refresh_token(authentication_code:) ⇒ Object
33 34 35 36 37 |
# File 'lib/g_sheets/oauth/offline.rb', line 33 def get_refresh_token(authentication_code:) @signet_client.code = authentication_code @signet_client.fetch_access_token! @signet_client.refresh_token end |