Skip to content

Instantly share code, notes, and snippets.

@sreeram-venkitesh
Created January 7, 2022 16:38
Show Gist options
  • Save sreeram-venkitesh/f6323697c3e34017d3690074cf847ce8 to your computer and use it in GitHub Desktop.
Save sreeram-venkitesh/f6323697c3e34017d3690074cf847ce8 to your computer and use it in GitHub Desktop.
Writing a Rails service to fetch users details from Okta

fetching all users from Okta

fetchUsers = OktaService.new(path="/api/v1/apps/#{ENV["OKTA_CLIENT_ID"]}/users")
response = fetchUsers.process
render status: :ok, json: {response: response}

fetching a single user from Okta

fetchUser = OktaService.new(path="/api/v1/users/#{params[:id]}")
userResponse = fetchUser.process
fetchUserGroup = OktaService.new(path="/api/v1/users/#{params[:id]}/groups")
groupResponse = fetchUserGroup.process
render status: :ok, json: {response: userResponse, group: groupResponse}

When fetching a single user the profile object has firstName and lastName. But when fetching all the users from the application endpoint, we have to use given_name and family_name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment