Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. As a third step we also fetch any users we have created either in the portal or through the Total Access API.
- 2. We create an Interceptor for Users.
- class UsersInterceptor < Gruf::Interceptors::ClientInterceptor
- def call(request_context:)
- logger.info "Got method #{request_context.method}!"
- yield
- end
- end
- begin
- client = ::Gruf::Client.new(
- service: ::Org::Users,
- options: {hostname: ENV['TOTAL_ACCESS_API_HOSTNAME']},
- client_options: {
- interceptors: [UsersInterceptor.new]
- }
- )
- auth_hash = { "authorization" => "Bearer #{response.message.auth_token}" }
- users = client.call(:ListUsers, { organization_slug: 'example_organization_slug' }, auth_hash)
- rescue Gruf::Client::Error => e
- logger.error "#{e.error.message}"
- end
- 3. In the users variable there will be an auth_token that is to be reused in the following request to assign users to a user group.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement