class D2L::Valence::AppContext
AppContext
¶ ↑
Class with contextual detail for the application (the ruby client)
Constants
- APP_ID_PARAM
- AUTH_KEY_PARAM
- AUTH_SERVICE_URI_PATH
- CALLBACK_URL_PARAM
Attributes
api_version[R]
app_id[R]
app_key[R]
brightspace_host[R]
Public Class Methods
new(brightspace_host:, app_id:, app_key:, api_version: '1.0')
click to toggle source
@param [Valence::Host] brightspace_host
Authenticating D2L
Brightspace Instance @param [String] app_id
Application ID provided by your D2L
admin @param [String] app_key
Application Key provided by your D2L
admin @param [String] api_version
Version of the Valence
API is use
# File lib/d2l/valence/app_context.rb, line 20 def initialize(brightspace_host:, app_id:, app_key:, api_version: '1.0') @brightspace_host = brightspace_host @app_id = app_id @app_key = app_key @api_version = api_version end
Public Instance Methods
auth_url(callback_uri)
click to toggle source
Generates a URL for authentication
@param [URI::Generic] callback_uri URI to redirect to post authentication @return [String] URL for authentication
# File lib/d2l/valence/app_context.rb, line 31 def auth_url(callback_uri) @brightspace_host.to_uri( path: AUTH_SERVICE_URI_PATH, query: query_params_using(callback_url: callback_uri.to_s) ).to_s end
Private Instance Methods
query_params_using(callback_url:)
click to toggle source
# File lib/d2l/valence/app_context.rb, line 40 def query_params_using(callback_url:) { APP_ID_PARAM => @app_id, AUTH_KEY_PARAM => Encrypt.generate_from(@app_key, callback_url), CALLBACK_URL_PARAM => CGI.escape(callback_url) }.map { |p, v| "#{p}=#{v}" }.join('&') end