class SparkApi::Authentication::BaseOAuth2Provider
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 the Spark platform @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
Attributes
Requirements for authorization_code grant type
Public Class Methods
# File lib/spark_api/authentication/oauth2.rb, line 207 def initialize(opts={}) Configuration::OAUTH2_KEYS.each do |key| send("#{key}=", opts[key]) if opts.include? key end @grant_type = :authorization_code end
Public Instance Methods
Load the current OAuth session returns - active OAuthSession
or nil
# File lib/spark_api/authentication/oauth2.rb, line 235 def load_session nil end
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).
# File lib/spark_api/authentication/oauth2.rb, line 225 def redirect(url) raise "To be implemented by client application" end
Save current session session - active OAuthSession
# File lib/spark_api/authentication/oauth2.rb, line 241 def save_session(session) end
Provides a default session time out returns - the session timeout length (in seconds)
# File lib/spark_api/authentication/oauth2.rb, line 247 def session_timeout 86400 # 1.day end