-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code
Description
Describe the problem you'd like to have solved
When attempting invitations to users for an org with
organizations().createInvitation(orgId, invitation)
the call is failing if we add roles to invitation object as below
List<String> roles = Arrays.asList("some role");
invitation.setRoles(new Roles(roles));
exception snippet
com.auth0.exception.APIException: Request failed with status code 400: Payload validation error: 'Expected type array but found type object' on property roles (List of roles IDs to associated with the user).
at com.auth0.net.ExtendedBaseRequest.createResponseException(ExtendedBaseRequest.java:131) ~[auth0-1.34.0.jar:1.34.0]
at com.auth0.net.ExtendedBaseRequest.parseResponse(ExtendedBaseRequest.java:66) ~[auth0-1.34.0.jar:1.34.0]
at com.auth0.net.BaseRequest.execute(BaseRequest.java:35) ~[auth0-1.34.0.jar:1.34.0]
It seems SDK is expecting Roles object here which inturn has List so the resulting json is turning out to be something like:
{
"inviter" : {
"name" : "xxxx"
},
"invitee" : {
"email" : "[email protected]"
},
"client_id" : "<<client-id>>",
"connection_id" : "<<con-id>>",
"send_invitation_email" : true,
"roles" : {
"roles" : [ "rol_7NdVtrUWWwpcYZz8", "rol_7NdVtrUWWwpcYZz8" ]
}
}
whereas organization invites post request https://auth0.com/docs/api/management/v2#!/Organizations/post_invitations is expecting roles to be a list
{
"inviter": {
"name": "Jane Doe"
},
"invitee": {
"email": "[email protected]"
},
"client_id": "AaiyAPdpYdesoKnqjj8HJqRn4T5titww",
"connection_id": "con_0000000000000001",
"app_metadata": {},
"user_metadata": {},
"ttl_sec": 0,
"roles": [
"rol_0000000000000001",
"rol_0000000000000002"
],
"send_invitation_email": true
}
Here is a snippet of how I am using SDK
Inviter inviter = new Inviter(inviterAddress);
Invitee invitee = new Invitee(userEmail);
Invitation invitation = new Invitation(inviter, invitee, appClientId);
invitation.setSendInvitationEmail(true);
List<String> roles = Arrays.asList(roleId);
Roles roles = new Roles(rolesList);
invitation.setRoles(roles);
invitation.setConnectionId(getConnectionId());
return executeWithRetry(tokenManager.getMgmt().organizations()
.createInvitation(orgId, invitation)).getId();
Describe the ideal solution
invitation.setRoles should accept List of Roles to be consistent with request pattern
Alternatives and current work-arounds
Please suggest if there are any alternatives or correct me if I am not invoking SDK properly
Additional information, if any
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code