Ruby Client Library
The Ruby client library allows you to integrate Passport with your Ruby application.
Source Code:
Gem:
To install the Passport Ruby Gem package run:
$ gem install inversoft-passport_client
Here is an example of using the PassportClient in your Ruby application.
# Construct the Passport Client with an example API key of 'API-KEY' and a host of 'http://localhost:9011'
client = Inversoft::PassportClient.new('API-KEY', 'http://localhost:9011',
->(cr) { cr.success_response },
->(cr) { raise "Status = #{cr.status} error body = #{cr.error_response}" })
# Create a user + registration
id = SecureRandom.uuid
client.register!(id, {
:user => {
:firstName => 'Ruby',
:lastName => 'Client',
:email => 'ruby.client.test@inversoft.com',
:password => 'password'
},
:registration => {
:applicationId => application_id,
:data => {
:attributes => {
:foo => 'bar'
},
:preferredLanguages => %w(en fr)
},
:roles => %w(user)
}
})
# Authenticate the user
response = client.login!({
:loginId => 'ruby.client.test@inversoft.com',
:password => 'password',
:applicationId => application_id
})
user = response.user