Zoho API: Get the user that is making the request

2019-05-31 14:03发布

I have seen Zoho APIs give us the option to get all kinds of user information, yet I cannot find any method to fetch info about the user that is currently making the request.

OAuth2 secured API's usually offer such an endpoint, like Google or Twitter do.

In their documentation there is something that looks like it:

https://www.zohoapis.com/crm/v2/users?type=CurrentUser

But then they shatter any hope with their explanation: CurrentUser - To get the list of current CRM users

Is there any known way achieve this?

标签: zoho
2条回答
一夜七次
2楼-- · 2019-05-31 14:42

This is the right endpoint: https://accounts.zoho.com/oauth/user/info

It requires the aaaserver.profile.READ scope.

Example Response:

{
    "ZUID": 123123123123, 
    "First_Name": "Example", 
    "Last_Name": "Name", 
    "Display_Name": "Example Name", 
    "Email": "example@email.com"
}
查看更多
叛逆
3楼-- · 2019-05-31 14:53

I have tested this personally and can confirm that the text on their docs is wrong.

They say:

CurrentUser - To get the list of current CRM users

But in reality, that endpoint really does return a single user everytime, the user to whom the oauth token belongs. So it's not returning "a list of current CRM users", but rather "the currently logged in user" - exactly as you desire.

So your gut was right, and that endpoint will achieve what you are trying to do.

查看更多
登录 后发表回答