Class: FlexmlsApi::Authentication::BaseOAuth2Provider
- Inherits:
-
Object
- Object
- FlexmlsApi::Authentication::BaseOAuth2Provider
- Defined in:
- lib/flexmls_api/authentication/oauth2.rb
Overview
OAuth2 configuration provider for applications
Applications planning to use OAuth2 authentication with the API must extend this class as part of the client configuration, providing values for the following attributes:
@authorization_uri - User oauth2 login page for flexmls
@access_uri - Location of the OAuth2 access token resource for the api. OAuth2 code and
credentials will be sent to this uri to generate an access token.
@redirect_uri - Application uri to redirect to
@client_id - OAuth2 provided application identifier
@client_secret - OAuth2 provided password for the client id
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
Requirements for authorization_code grant type.
-
#grant_type ⇒ Object
Returns the value of attribute grant_type.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BaseOAuth2Provider
constructor
A new instance of BaseOAuth2Provider.
-
#load_session ⇒ Object
Load the current OAuth session returns - active OAuthSession or nil.
-
#redirect(url) ⇒ Object
Application using the client must handle user redirect for user authentication.
-
#save_session(session) ⇒ Object
Save current session session - active OAuthSession.
-
#session_timeout ⇒ Object
Provides a default session time out returns - the session timeout length (in seconds).
Constructor Details
#initialize(opts = {}) ⇒ BaseOAuth2Provider
Returns a new instance of BaseOAuth2Provider.
133 134 135 136 137 138 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 133 def initialize(opts={}) Configuration::OAUTH2_KEYS.each do |key| send("#{key}=", opts[key]) if opts.include? key end @grant_type = :authorization_code end |
Instance Attribute Details
#code ⇒ Object
Requirements for authorization_code grant type
130 131 132 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 130 def code @code end |
#grant_type ⇒ Object
Returns the value of attribute grant_type.
131 132 133 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 131 def grant_type @grant_type end |
Instance Method Details
#load_session ⇒ Object
Load the current OAuth session returns - active OAuthSession or nil
161 162 163 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 161 def load_session nil end |
#redirect(url) ⇒ Object
Application using the client must handle user redirect for user authentication. For command line applications, this method is called prior to initial client requests so that
the process can notify the user to go to the url and retrieve the access_code for the app.
In a web based web application, this method can be mostly ignored. However, the web based application is then responsible for ensuring the code is saved to the the provider instance
prior to any client requests are performed (or the error below will be thrown).
151 152 153 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 151 def redirect(url) raise "To be implemented by client application" end |
#save_session(session) ⇒ Object
Save current session session - active OAuthSession
167 168 169 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 167 def save_session(session) end |
#session_timeout ⇒ Object
Provides a default session time out returns - the session timeout length (in seconds)
173 174 175 |
# File 'lib/flexmls_api/authentication/oauth2.rb', line 173 def session_timeout 86400 # 1.day end |