Usage

Errors and exceptions

OneLogin's API can return 400, 401, 403 or 404 when there was any issue executing the action. When that happens, the methods of the SDK will include error and errorMessage in the client. Use error and error_description of the Client to retrieve them.

In some scenarios there is an attribute not provided or invalid that causes the error,
when that happens in addition to the error_description a error_attribute is available
with the name of the attribute that caused the issue. Accesible at the client like:

client.error_attribute

Authentication

By default methods call internally to get_access_token if there is no valid access_token. You can also get tokens etc directly if needed.

Paging

All OneLogin API endpoints that support paging are returned as enumerations to save you keeping track of the paging cursor.

User take to limit the results or get all results by enumerating.

e.g.

# List the first name of all users
client.get_users.each do |user|
puts user.firstname
end# List the first name of all users starting with the 2nd user# `each` accepts a start param to skip first x results
client.get_users.each(1) do |user|
puts user.firstname
end# List the first 5 users with the name of Joe
client.get_users(firstname:'Joe').take(5).each do |user|
puts"#{user.firstname}#{user.lastname}"end# Get 10 event ids
client.get_events.take(10).map{|event| event.id }
# Get all roles
client.get_roles.to_a

For safety where some collections (e.g. get_events) have large numbers of resources there is a
limit of 1000 total results returned. You can override this with the max_results param during Client initialization.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.