Jump to content

User ID Mismatching Client


iwanndie

Recommended Posts

So, I am querying https://developers.whmcs.com/api-reference/validatelogin/ which returns a user id.

 

However, when using https://developers.whmcs.com/api-reference/getclientsdetails/ with that user id, it returns another clients details.

 

I've checked the responses, for one account, the user id is different to the client id, why is this? 

 

There's no way of converting user id to client id and visa versa, and the API doesn't return consistent data. 

 

The API will either return user id or client id, for example validate returns user_id, however getClientDetails requires clientid.

 

There's no consistency with the API at all, it seems very half-baked. 

 

Why?

Edited by iwanndie
Link to comment
Share on other sites

Are you logging in with the client user login or with a sub user / invited user?  Or is the client a sub user?  If with a sub / invited user, you are basically running in to the Client != Logged in User / auth user.  The ID returned from validatelogin isn't the ID of the client but the ID of the user that login belongs to.  https://developers.whmcs.com/advanced/authentication/  Welcome to the world of WHMCS 8.  yay!...?

So now you have the user's id and you want the client, but a user can have multiple clients tied to it and how are you suppose to know which is which?  Well, using the CurrentUser->client() function should return the current client logged in to, however, that only applies when logged in to WHMCS.  When using remote api, you will need to know the client beforehand for a sub / invited user.  You can get the list of clients a user is attached to via CurrentUser->user()->clients .  Then on your remote side, before doing actions, confirm which client the action should go to. 

EDIT: and as for half-baked the docs are at least that as I don't think the above is listed any where official and devs have to look around via vardump or get class method or other ways to get class info. 

Edited by steven99
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated