auth0 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -5
  3. data/CHANGELOG.md +46 -0
  4. data/README.md +81 -1
  5. data/auth0.gemspec +6 -6
  6. data/lib/auth0/api/authentication_endpoints.rb +16 -6
  7. data/lib/auth0/api/v2.rb +8 -4
  8. data/lib/auth0/api/v2/branding.rb +66 -0
  9. data/lib/auth0/api/v2/connections.rb +8 -2
  10. data/lib/auth0/api/v2/device_credentials.rb +3 -3
  11. data/lib/auth0/api/v2/jobs.rb +3 -1
  12. data/lib/auth0/api/v2/organizations.rb +335 -0
  13. data/lib/auth0/api/v2/tickets.rb +14 -2
  14. data/lib/auth0/api/v2/users.rb +12 -0
  15. data/lib/auth0/exception.rb +3 -1
  16. data/lib/auth0/mixins/httpproxy.rb +4 -1
  17. data/lib/auth0/mixins/initializer.rb +3 -1
  18. data/lib/auth0/mixins/validation.rb +14 -0
  19. data/lib/auth0/version.rb +1 -1
  20. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +38 -26
  21. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +38 -24
  22. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +38 -26
  23. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +41 -21
  24. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +41 -21
  25. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +41 -21
  26. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +41 -21
  27. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +41 -21
  28. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +45 -24
  29. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +75 -39
  30. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +39 -28
  31. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +37 -25
  32. data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
  33. data/spec/lib/auth0/api/v2/connections_spec.rb +5 -1
  34. data/spec/lib/auth0/api/v2/device_credentials_spec.rb +2 -2
  35. data/spec/lib/auth0/api/v2/jobs_spec.rb +11 -0
  36. data/spec/lib/auth0/api/v2/organizations_spec.rb +593 -0
  37. data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
  38. data/spec/lib/auth0/api/v2/users_spec.rb +19 -0
  39. data/spec/lib/auth0/client_spec.rb +79 -9
  40. data/spec/lib/auth0/mixins/httpproxy_spec.rb +8 -8
  41. data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
  42. metadata +21 -15
@@ -81,13 +81,15 @@ module Auth0
81
81
  # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
82
82
  # * :user_id [string] user_id of the identity.
83
83
  # * :provider [string] provider of the identity.
84
+ # @param organization_id [string] organization id
84
85
  #
85
86
  # @return [json] Returns the job status and properties.
86
- def send_verification_email(user_id, client_id = nil, identity: nil)
87
+ def send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil)
87
88
  raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
88
89
 
89
90
  request_params = { user_id: user_id }
90
91
  request_params[:client_id] = client_id unless client_id.nil?
92
+ request_params[:organization_id] = organization_id unless organization_id.nil?
91
93
 
92
94
  if identity
93
95
  unless identity.is_a? Hash
@@ -0,0 +1,335 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the organizations endpoints
5
+ module Organizations
6
+ include Auth0::Mixins::Validation
7
+
8
+ attr_reader :organizations_path
9
+
10
+ # Get all organizations.
11
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
12
+ # @param options [hash] The Hash options used to define the paging of rersults
13
+ # * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
14
+ # * :page [integer] The page number. Zero based.
15
+ # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
16
+ # @return [json] All Organizations
17
+ def organizations(options = {})
18
+ request_params = {
19
+ per_page: options.fetch(:per_page, nil),
20
+ page: options.fetch(:page, nil),
21
+ include_totals: options.fetch(:include_totals, nil)
22
+ }
23
+ get(organizations_path, request_params)
24
+ end
25
+ alias get_organizations organizations
26
+
27
+ # Create a new organization.
28
+ # @see ttps://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations
29
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations for available options
30
+ # @return [json] Returns the created organization.
31
+ def create_organization(options = {})
32
+ post(organizations_path, options)
33
+ end
34
+
35
+ # Get an organization by id. A token with read:organizations scope is required
36
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations_by_id
37
+ # @param organization_id [string] The organization_id of the user to retrieve.
38
+ #
39
+ # @return [json] Returns the organization with the given organization_id if it exists.
40
+ def organization(organization_id)
41
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
42
+ path = "#{organizations_path}/#{organization_id}"
43
+ get(path)
44
+ end
45
+
46
+ # Get an organization by name. A token with read:organizations scope is required.
47
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_name_by_name
48
+ # @param organization_name [string] The Organization name
49
+ #
50
+ # @return [json] Returns the organization with the given organization_name if it exists.
51
+ def organization_by_name(organization_name)
52
+ raise Auth0::InvalidParameter, 'Must supply a valid organization_name' if organization_name.to_s.empty?
53
+ path = "#{organizations_path}/name/#{organization_name}"
54
+ get(path)
55
+ end
56
+
57
+
58
+ # Deletes a single organization given its id
59
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organizations_by_id
60
+ # @param organization_id [string] The Organization ID
61
+ def delete_organization(organization_id)
62
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
63
+ path = "#{organizations_path}/#{organization_id}"
64
+ delete(path)
65
+ end
66
+
67
+ # Update an existing organization.
68
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id
69
+ # @param organization_id [string] The Organization ID
70
+ # @param body [hash] The optional parameters to update.
71
+ #
72
+ # @return [json] Returns the updated user.
73
+ def patch_organization(organization_id, body)
74
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
75
+ raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
76
+ path = "#{organizations_path}/#{organization_id}"
77
+ patch(path, body)
78
+ end
79
+ alias update_organization patch_organization
80
+
81
+ ### Organization Enabled Connections
82
+
83
+ # Get enabled connections in an Organization
84
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
85
+ # @param organization_id [string] The Organization ID
86
+ #
87
+ # @return [json] Returns the enabled connections for the given organization
88
+ def get_organizations_enabled_connections(organization_id)
89
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
90
+ path = "#{organizations_enabled_connections_path(organization_id)}"
91
+ get(path)
92
+ end
93
+
94
+ # Get enabled connection by id in an Organization
95
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections_by_connectionId
96
+ # @param organization_id [string] The Organization ID
97
+ # @param connection_id [string] The Connection id
98
+ #
99
+ # @return [json] Returns the connection for the given organization
100
+ def get_organizations_enabled_connection(organization_id, connection_id)
101
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
102
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
103
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
104
+ get(path)
105
+ end
106
+
107
+ # Update an eanbled connection in an Organization
108
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_enabled_connections_by_connectionId
109
+ # @param organization_id [string] The Organization ID
110
+ # @param connection_id [string] The Connection id
111
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
112
+ #
113
+ # @return [json] Returns the connection for the given organization
114
+ def patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil)
115
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
116
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
117
+ raise Auth0::InvalidParameter, 'Must supply a valid assign_membership_on_login value' if assign_membership_on_login.nil?
118
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
119
+
120
+ body = {}
121
+ body[:assign_membership_on_login] = assign_membership_on_login
122
+
123
+ patch(path, body)
124
+ end
125
+ alias update_organizations_enabled_connection patch_organizations_enabled_connection
126
+
127
+ # Add an enabled connection for an Organization
128
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_enabled_connections
129
+ # @param organization_id [string] The Organization ID
130
+ # @param connection_id [string] The Organization ID
131
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
132
+ #
133
+ # @return [json] Returns the connection for the given organization
134
+ def create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false)
135
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
136
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
137
+ path = "#{organizations_enabled_connections_path(organization_id)}"
138
+
139
+ body = {}
140
+ body[:assign_membership_on_login] = assign_membership_on_login
141
+ body[:connection_id] = connection_id
142
+
143
+ post(path, body)
144
+ end
145
+ alias add_organizations_enabled_connection create_organizations_enabled_connection
146
+
147
+ # Remove an enabled connection from an Organization
148
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_enabled_connections_by_connectionId
149
+ # @param organization_id [string] The Organization ID
150
+ # @param connection_id [string] The Connection id
151
+ def delete_organizations_enabled_connection(organization_id, connection_id)
152
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
153
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
154
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
155
+ delete(path)
156
+ end
157
+ alias remove_organizations_enabled_connection delete_organizations_enabled_connection
158
+
159
+ ### Organization Invites
160
+
161
+ # Get invites in an Organization
162
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations
163
+ # @param organization_id [string] The Organization ID
164
+ #
165
+ # @return [json] Returns the invites for the given organization
166
+ def get_organizations_invites(organization_id)
167
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
168
+ path = "#{organizations_invitations_path(organization_id)}"
169
+ get(path)
170
+ end
171
+
172
+ # Get invite by id in an Organization
173
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations_by_invitation_id
174
+ # @param organization_id [string] The Organization ID
175
+ # @param invitation_id [string] The invitation id
176
+ #
177
+ # @return [json] Returns the invitation for the given organization
178
+ def get_organizations_invite(organization_id, invitation_id)
179
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
180
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
181
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
182
+ get(path)
183
+ end
184
+
185
+ # Create an invitation in an organization
186
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
187
+ # @param organization_id [string] The Organization ID
188
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
189
+ # @return [json] Returns the invitation for the given organization
190
+ def create_organizations_invite(organization_id, options = {})
191
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
192
+ path = "#{organizations_invitations_path(organization_id)}"
193
+
194
+ post(path, options)
195
+ end
196
+ alias add_organizations_invite create_organizations_invite
197
+
198
+ # Delete an invitation to organization
199
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_invitations_by_invitation_id
200
+ # @param organization_id [string] The Organization ID
201
+ # @param invitation_id [string] The Invitation id
202
+ def delete_organizations_invite(organization_id, invitation_id)
203
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
204
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
205
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
206
+ delete(path)
207
+ end
208
+ alias remove_organizations_invite delete_organizations_invite
209
+
210
+ ### Organization Member
211
+
212
+ # Get Members in a Organization
213
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
214
+ # @param organization_id [string] The Organization ID
215
+ # @param user_id [string] The User ID
216
+ #
217
+ # @return [json] Returns the members for the given organization
218
+ def get_organizations_members(organization_id)
219
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
220
+ path = "#{organizations_members_path(organization_id)}"
221
+ get(path)
222
+ end
223
+
224
+ # Add members in an organization
225
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_members
226
+ # @param organization_id [string] The Organization ID
227
+ # @param members [array] Array of user IDs.
228
+ #
229
+ # @return [json] Returns the invitation for the given organization
230
+ def create_organizations_members(organization_id, members = [])
231
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
232
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
233
+ path = "#{organizations_members_path(organization_id)}"
234
+
235
+ body = {}
236
+ body[:members] = members
237
+
238
+ post(path, body)
239
+ end
240
+ alias add_organizations_members create_organizations_members
241
+
242
+ # Remove members from an organization
243
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_members
244
+ # @param organization_id [string] The Organization ID
245
+ # @param members [array] Array of user IDs.
246
+ def delete_organizations_members(organization_id, members = [])
247
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
248
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
249
+ path = "#{organizations_members_path(organization_id)}"
250
+
251
+ body = {}
252
+ body[:members] = members
253
+
254
+ delete(path, body)
255
+ end
256
+ alias remove_organizations_members delete_organizations_members
257
+
258
+ ### Organization Member Roles
259
+
260
+ # Get Roles assigned to a Member in an Organization
261
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organization_member_roles
262
+ # @param organization_id [string] The Organization ID
263
+ # @param user_id [string] The User ID
264
+ #
265
+ # @return [json] Returns the member_roles for the given organization
266
+ def get_organizations_member_roles(organization_id, user_id)
267
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
268
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
269
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
270
+ get(path)
271
+ end
272
+
273
+ # Assign roles to a member in an organization
274
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_organization_member_roles
275
+ # @param organization_id [string] The Organization ID
276
+ # @param user_id [string] The User ID
277
+ # @param roles [array] Array of role IDs.
278
+ #
279
+ # @return [json] Returns the invitation for the given organization
280
+ def create_organizations_member_roles(organization_id, user_id, roles = [])
281
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
282
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
283
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
284
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
285
+
286
+ body = {}
287
+ body[:roles] = roles
288
+
289
+ post(path, body)
290
+ end
291
+ alias add_organizations_member_roles create_organizations_member_roles
292
+
293
+ # Remove roles from a Member of an organization
294
+ # @https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles
295
+ # @param organization_id [string] The Organization ID
296
+ # @param user_id [string] The User ID
297
+ # @param roles [array] Array of role IDs.
298
+ def delete_organizations_member_roles(organization_id, user_id, roles = [])
299
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
300
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
301
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
302
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
303
+
304
+ body = {}
305
+ body[:roles] = roles
306
+
307
+ delete(path, body)
308
+ end
309
+ alias remove_organizations_member_roles delete_organizations_member_roles
310
+
311
+ private
312
+ # Organizations API path
313
+ def organizations_path
314
+ @organizations_path ||= '/api/v2/organizations'
315
+ end
316
+
317
+ def organizations_enabled_connections_path(org_id)
318
+ "#{organizations_path}/#{org_id}/enabled_connections"
319
+ end
320
+
321
+ def organizations_members_path(org_id)
322
+ "#{organizations_path}/#{org_id}/members"
323
+ end
324
+
325
+ def organizations_member_roles_path(org_id, user_id)
326
+ "#{organizations_path}/#{org_id}/members/#{user_id}/roles"
327
+ end
328
+
329
+ def organizations_invitations_path(org_id)
330
+ "#{organizations_path}/#{org_id}/invitations"
331
+ end
332
+ end
333
+ end
334
+ end
335
+ end
@@ -15,9 +15,11 @@ module Auth0
15
15
  # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
16
16
  # * :user_id [string] user_id of the identity.
17
17
  # * :provider [string] provider of the identity.
18
+ # @param client_id [string] client id
19
+ # @param organization_id [string] organization id
18
20
  #
19
21
  # @return [json] Returns the created ticket url.
20
- def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil)
22
+ def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
21
23
  if user_id.to_s.empty?
22
24
  raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
23
25
  end
@@ -27,6 +29,8 @@ module Auth0
27
29
  result_url: result_url,
28
30
  ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
29
31
  }
32
+ request_params[:client_id] = client_id unless client_id.nil?
33
+ request_params[:organization_id] = organization_id unless organization_id.nil?
30
34
 
31
35
  if identity
32
36
  unless identity.is_a? Hash
@@ -53,6 +57,8 @@ module Auth0
53
57
  # @param includeEmailInRedirect [boolean] Whether or not we include the email as part of the returnUrl
54
58
  # in the reset_email
55
59
  # @param new_password [string] The password to be set for the user once the ticket is used.
60
+ # @param client_id [string] client id
61
+ # @param organization_id [string] organization id
56
62
  #
57
63
  # @return [json] Returns the created ticket url.
58
64
  def post_password_change(
@@ -63,7 +69,10 @@ module Auth0
63
69
  ttl_sec: nil,
64
70
  mark_email_as_verified: nil,
65
71
  includeEmailInRedirect: nil,
66
- new_password: nil)
72
+ new_password: nil,
73
+ client_id: nil,
74
+ organization_id: nil
75
+ )
67
76
 
68
77
  booleans = [true, false]
69
78
  path = "#{tickets_path}/password-change"
@@ -77,6 +86,9 @@ module Auth0
77
86
  includeEmailInRedirect: booleans.include?(includeEmailInRedirect) ? includeEmailInRedirect : nil,
78
87
  new_password: new_password
79
88
  }
89
+ request_params[:client_id] = client_id unless client_id.nil?
90
+ request_params[:organization_id] = organization_id unless organization_id.nil?
91
+
80
92
  post(path, request_params)
81
93
  end
82
94
 
@@ -308,6 +308,18 @@ module Auth0
308
308
  post "#{users_path}/#{user_id}/multifactor/actions/invalidate-remember-browser"
309
309
  end
310
310
 
311
+
312
+ # Get a list of organizations for a user.
313
+ #
314
+ # @param user_id [string] The user_id of the permissions to get.
315
+ #
316
+ # @return [json] Returns organizations for the given user_id.
317
+ def get_user_organizations(user_id)
318
+ raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
319
+
320
+ get "#{users_path}/#{user_id}/organizations"
321
+ end
322
+
311
323
  private
312
324
 
313
325
  # Users API path
@@ -38,6 +38,8 @@ module Auth0
38
38
  class MissingUserId < Auth0::Exception; end
39
39
  # exception for unset client_id
40
40
  class MissingClientId < Auth0::Exception; end
41
+ # exception for unset organization_id
42
+ class MissingOrganizationId < Auth0::Exception; end
41
43
  # exception for an unset parameter
42
44
  class MissingParameter < Auth0::Exception; end
43
45
  # Api v2 access denied
@@ -51,7 +53,7 @@ module Auth0
51
53
  # Auth0 API rate-limiting encountered
52
54
  class RateLimitEncountered < Auth0::HTTPError
53
55
  def reset
54
- Time.at(headers['X-RateLimit-Reset']).utc
56
+ Time.at(Integer(headers[:x_ratelimit_reset])).utc
55
57
  end
56
58
  end
57
59
 
@@ -26,7 +26,10 @@ module Auth0
26
26
  call(:delete, url(safe_path), timeout, headers, body.to_json)
27
27
  elsif method == :post_file
28
28
  body.merge!(multipart: true)
29
- call(:post, url(safe_path), timeout, headers, body)
29
+ # Ignore the default Content-Type headers and let the HTTP client define them
30
+ post_file_headers = headers.slice(*headers.keys - ['Content-Type'])
31
+ # Actual call with the altered headers
32
+ call(:post, url(safe_path), timeout, post_file_headers, body)
30
33
  else
31
34
  call(method, url(safe_path), timeout, headers, body.to_json)
32
35
  end