Class: Okta::DirectoryService
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- Okta::DirectoryService
- Defined in:
- lib/okta/directory_service.rb
Instance Method Summary collapse
Methods inherited from Common::Client::Base
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Method Details
#scopes(category) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/okta/directory_service.rb', line 5 def scopes(category) # if the category is health we need to call a specific server instead of relying on querying by name, # since there is a 'health/systems' auth server that would affect results base_url = Settings..auth_server.url category = category.downcase scopes_url = "#{base_url}/#{category}/scopes" headers = { apiKey: Settings.connected_apps_api.connected_apps.api_key, accesskey: Settings.connected_apps_api.connected_apps.auth_access_key } response = Faraday.get(scopes_url, {}, headers) if response.status == 200 begin JSON.parse(response.body) # response has 200 status but content of response body is not valid json rescue JSON::ParserError { 'error' => 'Failed to parse JSON response' } end elsif response.status == 204 # category is found but no scopes are returned (204) [] else raise Faraday::Error, "status: #{response.status}" end end |