Class: GcalMapper::Authentification
- Inherits:
-
Object
- Object
- GcalMapper::Authentification
- Defined in:
- lib/gcal_mapper/authentification.rb,
lib/gcal_mapper/authentification/base.rb,
lib/gcal_mapper/authentification/oauth2.rb,
lib/gcal_mapper/authentification/assertion.rb
Overview
Abstract which type of authentification is required
Defined Under Namespace
Classes: Assertion, Base, Oauth2
Constant Summary collapse
- REQUEST_URL =
url where to request to authentificate
'https://accounts.google.com/o/oauth2/token'
Instance Attribute Summary collapse
-
#client_email ⇒ Object
readonly
for assertion authentification.
-
#file ⇒ Object
readonly
file that is needed for authentification.
-
#password ⇒ Object
readonly
password for the p12 file.
Instance Method Summary collapse
-
#access_token ⇒ string
Gives the access token.
-
#authenticate ⇒ Bool
do the authentification for one of the right authentification method.
-
#initialize(file, client_email = nil, user_email = nil, password = 'notasecret') ⇒ Authentification
constructor
intialize client info needed for connection to Oauth2.
-
#refresh_token ⇒ string
refresh the access token.
Constructor Details
#initialize(file, client_email = nil, user_email = nil, password = 'notasecret') ⇒ Authentification
intialize client info needed for connection to Oauth2.
21 22 23 24 25 26 27 |
# File 'lib/gcal_mapper/authentification.rb', line 21 def initialize(file, client_email=nil, user_email=nil, password='notasecret') @file = File.(file) @client_email = client_email @user_email = user_email @password = password raise GcalMapper::AuthFileError if !File.exist?(@file) end |
Instance Attribute Details
#client_email ⇒ Object (readonly)
for assertion authentification
12 13 14 |
# File 'lib/gcal_mapper/authentification.rb', line 12 def client_email @client_email end |
#file ⇒ Object (readonly)
file that is needed for authentification
11 12 13 |
# File 'lib/gcal_mapper/authentification.rb', line 11 def file @file end |
#password ⇒ Object (readonly)
password for the p12 file
13 14 15 |
# File 'lib/gcal_mapper/authentification.rb', line 13 def password @password end |
Instance Method Details
#access_token ⇒ string
Gives the access token
45 46 47 |
# File 'lib/gcal_mapper/authentification.rb', line 45 def access_token @auth.access_token end |
#authenticate ⇒ Bool
do the authentification for one of the right authentification method
32 33 34 35 36 37 38 39 40 |
# File 'lib/gcal_mapper/authentification.rb', line 32 def authenticate if client_email==nil @auth = Authentification::Oauth2.new(@file) else @auth = Authentification::Assertion.new(@file, @client_email, @user_email, @password) end !access_token.nil? end |
#refresh_token ⇒ string
refresh the access token
52 53 54 |
# File 'lib/gcal_mapper/authentification.rb', line 52 def refresh_token @auth.refresh_token end |