Class: GcalMapper::Authentification::Assertion
- Defined in:
- lib/gcal_mapper/authentification/assertion.rb
Overview
make the authentification for service account and request data from google calendar.
Constant Summary collapse
- ASSERTION_SCOPE =
scope for assertion
'https://www.google.com/calendar/feeds/'
- JWT_HEADER =
header of the jwt to send
{'alg' => 'RS256', 'typ' => 'JWT'}
- ASSERTION_TYPE =
url to specify which type of assertion
'http://oauth.net/grant_type/jwt/1.0/bearer'
Instance Attribute Summary collapse
-
#client_email ⇒ Object
the email given by google for the service account.
-
#user_email ⇒ Object
the email of the user to impersonate.
Instance Method Summary collapse
-
#access_token ⇒ String
give the acess token for th application and refresh if it is outdated.
-
#initialize(p12_file, client_email, user_email, password) ⇒ Assertion
constructor
New object.
-
#refresh_token ⇒ String
refresh the token by asking for a new one.
Constructor Details
#initialize(p12_file, client_email, user_email, password) ⇒ Assertion
New object
24 25 26 27 28 29 30 31 |
# File 'lib/gcal_mapper/authentification/assertion.rb', line 24 def initialize(p12_file, client_email, user_email, password) @client_email = client_email @p12_file = p12_file @user_email = user_email @password = password request_token @validity = Time.now.getutc.to_i end |
Instance Attribute Details
#client_email ⇒ Object
the email given by google for the service account
15 16 17 |
# File 'lib/gcal_mapper/authentification/assertion.rb', line 15 def client_email @client_email end |
#user_email ⇒ Object
the email of the user to impersonate
16 17 18 |
# File 'lib/gcal_mapper/authentification/assertion.rb', line 16 def user_email @user_email end |
Instance Method Details
#access_token ⇒ String
give the acess token for th application and refresh if it is outdated
36 37 38 39 40 41 42 |
# File 'lib/gcal_mapper/authentification/assertion.rb', line 36 def access_token if Time.now.getutc.to_i - @validity > 3600 refresh_token end @access_token end |
#refresh_token ⇒ String
refresh the token by asking for a new one
47 48 49 |
# File 'lib/gcal_mapper/authentification/assertion.rb', line 47 def refresh_token request_token end |